Class: Cadet::Relationship
- Inherits:
-
Object
- Object
- Cadet::Relationship
show all
- Defined in:
- lib/cadet/relationship.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(relationship) ⇒ Relationship
Returns a new instance of Relationship.
5
6
7
|
# File 'lib/cadet/relationship.rb', line 5
def initialize(relationship)
@underlying = relationship
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/cadet/relationship.rb', line 33
def method_missing(name, *args, &block)
case name
when /([A-z_]*)_to$/
self.class.class_eval "
def #{name}(value)
end_node.create_outgoing(value, :#{$1})
end
"
self.send(name, *args, &block)
else
raise NotImplementedError
end
end
|
Instance Attribute Details
#underlying ⇒ Object
Returns the value of attribute underlying.
3
4
5
|
# File 'lib/cadet/relationship.rb', line 3
def underlying
@underlying
end
|
Instance Method Details
#==(other_rel) ⇒ Object
9
10
11
|
# File 'lib/cadet/relationship.rb', line 9
def == other_rel
@underlying.getId == other_rel.underlying.getId
end
|
#[](property) ⇒ Object
17
18
19
|
# File 'lib/cadet/relationship.rb', line 17
def [] (property)
@underlying.getProperty(property.to_java_string)
end
|
#[]=(property, value) ⇒ Object
13
14
15
|
# File 'lib/cadet/relationship.rb', line 13
def []= (property, value)
@underlying.setProperty(property.to_java_string, value)
end
|
#end_node ⇒ Object
29
30
31
|
# File 'lib/cadet/relationship.rb', line 29
def end_node
Node.new @underlying.getEndNode
end
|
#get_other_node(node) ⇒ Object
21
22
23
|
# File 'lib/cadet/relationship.rb', line 21
def get_other_node(node)
Node.new @underlying.getOtherNode(node.underlying)
end
|
#start_node ⇒ Object
25
26
27
|
# File 'lib/cadet/relationship.rb', line 25
def start_node
Node.new @underlying.getStartNode
end
|