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
69 70 71 |
# File 'lib/active_graph/relationship/persistence.rb', line 69 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.
74 75 76 |
# File 'lib/active_graph/relationship/persistence.rb', line 74 def create!(*args) new(*args).tap(&:save!) end |
#create_method ⇒ Object
78 79 80 |
# File 'lib/active_graph/relationship/persistence.rb', line 78 def create_method creates_unique? ? :create_unique : :create end |
#load_entity(id) ⇒ Object
82 83 84 |
# File 'lib/active_graph/relationship/persistence.rb', line 82 def load_entity(id) query_as(id).pluck(:r).first end |
#query_as(neo_id, var = :r) ⇒ Object
86 87 88 |
# File 'lib/active_graph/relationship/persistence.rb', line 86 def query_as(neo_id, var = :r) ActiveGraph::Base.new_query.match("()-[#{var}]->()").where(var => {neo_id: neo_id}) end |