class ActiveRedis::AllList::ListWriter

Public Class Methods

new(object, name, options = {}) click to toggle source
# File lib/active_redis/all_list.rb, line 43
def initialize(object, name, options = {})
  @object, @name, @options = object, name, options
end

Public Instance Methods

add() click to toggle source
# File lib/active_redis/all_list.rb, line 47
def add
  @object.class.redis.zadd(key, Time.now.to_f, @object.id) if should_add?
end
key() click to toggle source
# File lib/active_redis/all_list.rb, line 55
def key
  @object.class.list_key(@name)
end
remove() click to toggle source
# File lib/active_redis/all_list.rb, line 51
def remove
  @object.class.redis.zrem(key, @object.id)
end

Private Instance Methods

should_add?() click to toggle source
# File lib/active_redis/all_list.rb, line 61
def should_add?
  if @options[:if].present?
    @options[:if].call(@object)
  else
    true
  end
end