Method: ActiveNode::Relationship#save

Defined in:
lib/active_node/relationship.rb

#save(association) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/active_node/relationship.rb', line 21

def save(association)
  if new_record?
    from=association.owner
    to=other
    if association.reflection.direction == :incoming
      from, to = to, from
    end
    @id = get_id(Neo.db.create_relationship(association.reflection.type, from.id, to.id, @hash)).to_i
  else
    Neo.db.reset_relationship_properties(id, @hash.select { |_, v| v.present? })
  end
end