Skip to content

Commit

Permalink
Merge pull request #33 from heelhook/master
Browse files Browse the repository at this point in the history
Support to find attributes of relationship
  • Loading branch information
maxdemarzi committed Mar 27, 2012
2 parents 6e9fe11 + 5a83e3a commit 5207643
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ The Neo4j ID is available by using node.neo_id .
new_rel.start_node # Get the start/from node of a relationship
new_rel.end_node # Get the end/to node of a relationship
new_rel.other_node(n2) # Get the other node of a relationship
new_rel.attributes # Get the attributes of the relationship as an array

existing_rel = Neography::Relationship.load(12) # Get an existing relationship by id
existing_rel.del # Delete a relationship
Expand Down
7 changes: 6 additions & 1 deletion lib/neography/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def del
def exist?
!self.start_node.neo_server.get_relationship(self.neo_id).nil?
end

def attributes
attrs = self.methods - OpenStruct.instance_methods - Neography::Relationship.instance_methods
attrs.values_at(*attrs.each_index.select {|i| i.even?})
end

def other_node(node)
if node == @start_node
Expand All @@ -65,4 +70,4 @@ def other_node(node)
end

end
end
end

0 comments on commit 5207643

Please sign in to comment.