Class: Restruct::Structure
- Inherits:
-
Object
- Object
- Restruct::Structure
- Defined in:
- lib/restruct/structure.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
- #==(object) ⇒ Object (also: #eql?)
- #destroy ⇒ Object
- #dump ⇒ Object
-
#initialize(options = {}) ⇒ Structure
constructor
A new instance of Structure.
- #restore(dump) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Structure
Returns a new instance of Structure.
6 7 8 9 |
# File 'lib/restruct/structure.rb', line 6 def initialize(={}) @redis = [:redis] || Restruct.redis @id = Id.new [:id] || Restruct.generate_id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/restruct/structure.rb', line 4 def id @id end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
4 5 6 |
# File 'lib/restruct/structure.rb', line 4 def redis @redis end |
Instance Method Details
#==(object) ⇒ Object Also known as: eql?
11 12 13 14 15 |
# File 'lib/restruct/structure.rb', line 11 def ==(object) object.class == self.class && object.id == id && object.redis == redis end |
#destroy ⇒ Object
27 28 29 |
# File 'lib/restruct/structure.rb', line 27 def destroy redis.call 'DEL', id end |
#dump ⇒ Object
18 19 20 |
# File 'lib/restruct/structure.rb', line 18 def dump redis.call 'DUMP', id end |
#restore(dump) ⇒ Object
22 23 24 25 |
# File 'lib/restruct/structure.rb', line 22 def restore(dump) destroy redis.call 'RESTORE', id, 0, dump end |