module Redis::Objects::ClassMethods

Class methods that appear in your class when you include Redis::Objects.

Attributes

redis_objects[W]

Internal list of objects

Public Instance Methods

first_ancestor_with(name) click to toggle source
# File lib/redis/objects.rb, line 149
def first_ancestor_with(name)
  if redis_objects && redis_objects.key?(name.to_sym)
    self
  elsif superclass && superclass.respond_to?(:redis_objects)
    superclass.first_ancestor_with(name)
  end
end
redis() click to toggle source
# File lib/redis/objects.rb, line 94
def redis
  @redis || Objects.redis
end
redis=(conn) click to toggle source

Enable per-class connections (eg, User and Post can use diff redis-server)

# File lib/redis/objects.rb, line 90
def redis=(conn)
  @redis = Objects::ConnectionPoolProxy.proxy_if_needed(conn)
end
redis_id_field(id=nil) click to toggle source
# File lib/redis/objects.rb, line 157
def redis_id_field(id=nil)
  @redis_id_field = id || @redis_id_field

  if superclass && superclass.respond_to?(:redis_id_field)
    @redis_id_field ||= superclass.redis_id_field
  end

  @redis_id_field ||= :id
end
redis_objects() click to toggle source
# File lib/redis/objects.rb, line 100
def redis_objects
  @redis_objects ||= {}
end
redis_options(name) click to toggle source
# File lib/redis/objects.rb, line 114
def redis_options(name)
  klass = first_ancestor_with(name)
  return klass.redis_objects[name.to_sym] || {}
end
redis_prefix=(redis_prefix) click to toggle source

Set the Redis redis_prefix to use. Defaults to model_name

# File lib/redis/objects.rb, line 105
def redis_prefix=(redis_prefix) @redis_prefix = redis_prefix end