Class: Redpear::Store::Value
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Base::IS_NIL, Base::IS_ONE, Base::IS_TRUE, Base::IS_ZERO, Base::PICK_FIRST, Base::TO_INT, Base::TO_SET
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Comparator.
-
#append(value) ⇒ Object
(also: #<<)
Appends a ‘value`.
-
#get ⇒ String
The value.
-
#nil? ⇒ Boolean
True, if value is nil.
- #replace(*a) ⇒ Object
-
#respond_to?(method, *a) ⇒ Boolean
True, if responds to ‘method`.
-
#set(value) ⇒ Object
Sets the value.
- #value ⇒ Object
- #value=(*a) ⇒ Object
Methods inherited from Base
#clear, #exists?, #expire, #expire_at, #expire_in, #initialize, #inspect, #purge!, temporary, #ttl, #type, #watch
Constructor Details
This class inherits a constructor from Redpear::Store::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *a, &b) ⇒ Object (protected)
71 72 73 74 |
# File 'lib/redpear/store/value.rb', line 71 def method_missing(method, *a, &b) base = (value || "") base.respond_to?(method) ? base.send(method, *a, &b) : super end |
Instance Method Details
#==(other) ⇒ Boolean
Comparator
45 46 47 48 49 50 51 52 |
# File 'lib/redpear/store/value.rb', line 45 def ==(other) case value = self.value when Redis::Future value.instance_eval { @transformation = Kernel.lambda {|v| v == other } } else value == other end end |
#append(value) ⇒ Object Also known as: <<
Appends a ‘value`
36 37 38 39 |
# File 'lib/redpear/store/value.rb', line 36 def append(value) conn.append(key, value) self end |
#get ⇒ String
Returns the value.
8 9 10 |
# File 'lib/redpear/store/value.rb', line 8 def get conn.get(key) end |
#nil? ⇒ Boolean
Returns true, if value is nil.
55 56 57 58 59 60 61 62 |
# File 'lib/redpear/store/value.rb', line 55 def nil? case value = self.value when Redis::Future value.instance_eval { @transformation = IS_NIL } else value.nil? end end |
#replace(*a) ⇒ Object
29 30 31 |
# File 'lib/redpear/store/value.rb', line 29 def replace(*a) set(*a) end |
#respond_to?(method, *a) ⇒ Boolean
Returns true, if responds to ‘method`.
65 66 67 |
# File 'lib/redpear/store/value.rb', line 65 def respond_to?(method, *a) super || (value || "").respond_to?(method, *a) end |
#set(value) ⇒ Object
Sets the value
19 20 21 |
# File 'lib/redpear/store/value.rb', line 19 def set(value) conn.set(key, value) end |
#value ⇒ Object
13 14 15 |
# File 'lib/redpear/store/value.rb', line 13 def value get end |
#value=(*a) ⇒ Object
24 25 26 |
# File 'lib/redpear/store/value.rb', line 24 def value=(*a) set(*a) end |