Class: Holistic::Database::Relation
- Inherits:
-
Set
- Object
- Set
- Holistic::Database::Relation
- Defined in:
- lib/holistic/database/relation.rb
Instance Method Summary collapse
- #add!(related_node) ⇒ Object
- #delete!(related_node) ⇒ Object
-
#initialize(node:, name:, inverse_of:) ⇒ Relation
constructor
A new instance of Relation.
Constructor Details
#initialize(node:, name:, inverse_of:) ⇒ Relation
Returns a new instance of Relation.
4 5 6 7 8 9 10 |
# File 'lib/holistic/database/relation.rb', line 4 def initialize(node:, name:, inverse_of:) @node = node @name = name @inverse_of = inverse_of super() end |
Instance Method Details
#add!(related_node) ⇒ Object
12 13 14 15 |
# File 'lib/holistic/database/relation.rb', line 12 def add!() @node.relations[@name].add() .relations[@inverse_of].add(@node) end |
#delete!(related_node) ⇒ Object
17 18 19 20 |
# File 'lib/holistic/database/relation.rb', line 17 def delete!() @node.relations[@name].delete() .relations[@inverse_of].delete(@node) end |