Module: ActiveGraph::Relationship::Persistence::ClassMethods
- Defined in:
- lib/active_graph/relationship/persistence.rb
Instance Method Summary collapse
-
#create(*args) ⇒ Object
Creates a new relationship between objects.
-
#create!(*args) ⇒ Object
Same as #create, but raises an error if there is a problem during save.
- #create_method ⇒ Object
- #load_entity(id) ⇒ Object
- #query_as(neo_id, var = :r) ⇒ Object
Instance Method Details
#create(*args) ⇒ Object
Creates a new relationship between objects
71 72 73 |
# File 'lib/active_graph/relationship/persistence.rb', line 71 def create(*args) new(*args).tap(&:save) end |
#create!(*args) ⇒ Object
Same as #create, but raises an error if there is a problem during save.
76 77 78 |
# File 'lib/active_graph/relationship/persistence.rb', line 76 def create!(*args) new(*args).tap(&:save!) end |
#create_method ⇒ Object
80 81 82 |
# File 'lib/active_graph/relationship/persistence.rb', line 80 def create_method creates_unique? ? :create_unique : :create end |
#load_entity(id) ⇒ Object
84 85 86 |
# File 'lib/active_graph/relationship/persistence.rb', line 84 def load_entity(id) query_as(id).pluck(:r).first end |
#query_as(neo_id, var = :r) ⇒ Object
88 89 90 |
# File 'lib/active_graph/relationship/persistence.rb', line 88 def query_as(neo_id, var = :r) ActiveGraph::Base.new_query.match("()-[#{var}]->()").where(var => { neo_id: }) end |