Module: Redis::Attrs::ClassMethods

Defined in:
lib/redis-attrs.rb

Instance Method Summary collapse

Instance Method Details

#redisObject


17
18
19
# File 'lib/redis-attrs.rb', line 17

def redis
  Redis::Attrs.redis
end

#redis_attr(name, type, options = {}) ⇒ Object

Raises:

  • (ArgumentError)

33
34
35
36
37
38
39
# File 'lib/redis-attrs.rb', line 33

def redis_attr(name, type, options = {})
  @redis_attrs ||= []
  klass = Redis::Attrs.supported_types[type]
  raise ArgumentError, "Unknown Redis::Attr type #{type}" if klass.nil?
  attr = klass.new(self, name, type, options)
  @redis_attrs << attr
end

#redis_attrs(attrs = nil) ⇒ Object


25
26
27
28
29
30
31
# File 'lib/redis-attrs.rb', line 25

def redis_attrs(attrs = nil)
  @redis_attrs ||= []
  return @redis_attrs if attrs.nil?
  attrs.each do |name, type|
    redis_attr name, type
  end
end

#redis_key_prefixObject


21
22
23
# File 'lib/redis-attrs.rb', line 21

def redis_key_prefix
  @redis_key_refix ||= ActiveSupport::Inflector.underscore(name)
end