Skip to content

Commit

Permalink
added cardinality for relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
blizkreeg committed Jan 4, 2014
1 parent 8fd92be commit ac34e56
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/deja/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Relationship < Model
attr_accessor :start_node, :end_node

class << self
attr_reader :directionality
attr_reader :directionality, :cardinality

@directionality = {}

Expand All @@ -18,6 +18,8 @@ def from(from_type=nil, opts={})
@directionality ||= {}
@directionality[from_type] ||= []
@directionality[from_type] << to_type

@cardinality = opts[:cardinality] || nil
end

def valid_direction?(from_type=nil, to_type=nil)
Expand All @@ -33,6 +35,10 @@ def label
return self.name.underscore.to_sym
end

def cardinality
@cardinality
end

def find(id_or_index)
relationship = Deja::Query.load_relationship(id_or_index)
relationize(relationship)
Expand Down

0 comments on commit ac34e56

Please sign in to comment.