Class: Restruct::Structure
- Inherits:
-
Object
- Object
- Restruct::Structure
show all
- Defined in:
- lib/restruct/structure.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Structure
Returns a new instance of Structure.
6
7
8
9
|
# File 'lib/restruct/structure.rb', line 6
def initialize(options={})
@connection = options[:connection] || Restruct.connection
@id = Id.new options[:id] || Restruct.generate_id
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
4
5
6
|
# File 'lib/restruct/structure.rb', line 4
def connection
@connection
end
|
#id ⇒ Object
Returns the value of attribute id.
4
5
6
|
# File 'lib/restruct/structure.rb', line 4
def id
@id
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.connection == connection
end
|
#destroy ⇒ Object
27
28
29
|
# File 'lib/restruct/structure.rb', line 27
def destroy
connection.lazy 'DEL', id
end
|
#dump ⇒ Object
18
19
20
|
# File 'lib/restruct/structure.rb', line 18
def dump
connection.call 'DUMP', id
end
|
#exists? ⇒ Boolean
31
32
33
|
# File 'lib/restruct/structure.rb', line 31
def exists?
connection.call('EXISTS', id) == 1
end
|
#restore(dump) ⇒ Object
22
23
24
25
|
# File 'lib/restruct/structure.rb', line 22
def restore(dump)
destroy
connection.lazy 'RESTORE', id, 0, dump
end
|