class Rediscord::RecordSet
Attributes
force_update[R]
key[R]
redis[R]
Public Class Methods
new(options)
click to toggle source
# File lib/rediscord/record_set.rb, line 5 def initialize(options) @key = options[:key] @redis = options[:redis] end
Public Instance Methods
after_create(record)
click to toggle source
# File lib/rediscord/record_set.rb, line 14 def after_create(record) redis.sadd(key_for(record), record.id) end
after_destroy(record)
click to toggle source
# File lib/rediscord/record_set.rb, line 18 def after_destroy(record) redis.srem(key_for(record), record.id) end
after_update(record, prev_record)
click to toggle source
# File lib/rediscord/record_set.rb, line 22 def after_update(record, prev_record) _key_was = key_for(prev_record) _key = key_for(record) if force_update || _key_was != _key redis.srem(_key_was, record.id) redis.sadd(_key, record.id) end end
key_for(record)
click to toggle source
# File lib/rediscord/record_set.rb, line 10 def key_for(record) key.call(record) end