Class: Chimera::RedisObjectProxy::Base
- Inherits:
-
Object
- Object
- Chimera::RedisObjectProxy::Base
show all
- Defined in:
- lib/chimera/redis_objects.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(owner, name, extra_opts) ⇒ Base
Returns a new instance of Base.
48
49
50
51
52
53
54
55
56
|
# File 'lib/chimera/redis_objects.rb', line 48
def initialize(owner, name, )
unless owner and owner.id
raise(Chimera::Errors::MissingId)
end
@owner = owner
@name = name
@extra_opts =
end
|
Instance Attribute Details
Returns the value of attribute extra_opts.
47
48
49
|
# File 'lib/chimera/redis_objects.rb', line 47
def
@extra_opts
end
|
#name ⇒ Object
Returns the value of attribute name.
47
48
49
|
# File 'lib/chimera/redis_objects.rb', line 47
def name
@name
end
|
#owner ⇒ Object
Returns the value of attribute owner.
47
48
49
|
# File 'lib/chimera/redis_objects.rb', line 47
def owner
@owner
end
|
Instance Method Details
#connection ⇒ Object
58
59
60
|
# File 'lib/chimera/redis_objects.rb', line 58
def connection
self.owner.class.connection(:redis)
end
|
#decode(val) ⇒ Object
74
75
76
77
78
|
# File 'lib/chimera/redis_objects.rb', line 74
def decode(val)
return nil if val.nil?
return "" if val == ""
YAML.load(val)
end
|
#destroy ⇒ Object
66
67
68
|
# File 'lib/chimera/redis_objects.rb', line 66
def destroy
connection.del(self.key)
end
|
#encode(val) ⇒ Object
70
71
72
|
# File 'lib/chimera/redis_objects.rb', line 70
def encode(val)
YAML.dump(val)
end
|
#key ⇒ Object
62
63
64
|
# File 'lib/chimera/redis_objects.rb', line 62
def key
"#{self.class.to_s}::RedisObjects::#{name}::#{self.owner.id}"
end
|