Class: Holistic::Database::Node
- Inherits:
-
Object
- Object
- Holistic::Database::Node
- Defined in:
- lib/holistic/database/node.rb
Direct Known Subclasses
Holistic::Document::File::Record, Ruby::Reference::Record, Ruby::Scope::Record
Instance Attribute Summary collapse
-
#__database__ ⇒ Object
Returns the value of attribute __database__.
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#relations ⇒ Object
Returns the value of attribute relations.
Instance Method Summary collapse
- #attr(attribute_name) ⇒ Object
- #has_many(connection_name) ⇒ Object
- #has_one(connection_name) ⇒ Object
-
#initialize(id, attributes) ⇒ Node
constructor
A new instance of Node.
- #relation(relation_name) ⇒ Object
Constructor Details
#initialize(id, attributes) ⇒ Node
Returns a new instance of Node.
6 7 8 9 10 |
# File 'lib/holistic/database/node.rb', line 6 def initialize(id, attributes) @id = id @attributes = attributes @relations = ::Hash.new(&method(:build_relation_hash)) end |
Instance Attribute Details
#__database__ ⇒ Object
Returns the value of attribute __database__.
4 5 6 |
# File 'lib/holistic/database/node.rb', line 4 def __database__ @__database__ end |
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/holistic/database/node.rb', line 4 def attributes @attributes end |
#relations ⇒ Object
Returns the value of attribute relations.
4 5 6 |
# File 'lib/holistic/database/node.rb', line 4 def relations @relations end |
Instance Method Details
#attr(attribute_name) ⇒ Object
12 13 14 |
# File 'lib/holistic/database/node.rb', line 12 def attr(attribute_name) @attributes[attribute_name] end |
#has_many(connection_name) ⇒ Object
20 21 22 |
# File 'lib/holistic/database/node.rb', line 20 def has_many(connection_name) @relations[connection_name].to_a end |
#has_one(connection_name) ⇒ Object
24 25 26 |
# File 'lib/holistic/database/node.rb', line 24 def has_one(connection_name) @relations[connection_name].first end |
#relation(relation_name) ⇒ Object
16 17 18 |
# File 'lib/holistic/database/node.rb', line 16 def relation(relation_name) @relations[relation_name] end |