Class: Redis::Attrs::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/redis-attrs/base.rb

Direct Known Subclasses

Complex, Scalar

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, name, type, options) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/redis-attrs/base.rb', line 6

def initialize(klass, name, type, options)
  @klass, @name, @type, @options = klass, name, type, options
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



4
5
6
# File 'lib/redis-attrs/base.rb', line 4

def klass
  @klass
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/redis-attrs/base.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/redis-attrs/base.rb', line 4

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/redis-attrs/base.rb', line 4

def type
  @type
end

Instance Method Details

#redisObject



10
11
12
# File 'lib/redis-attrs/base.rb', line 10

def redis
  Redis::Attrs.redis
end

#redis_key(id) ⇒ Object



14
15
16
17
# File 'lib/redis-attrs/base.rb', line 14

def redis_key(id)
  raise "id attribute is required in order to properly store Redis attributes" if id.nil?
  "#{klass.redis_key_prefix}:#{id}:#{name}"
end