Class: DataMapper::Query::Path
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Equalizer
equalize
Methods included from Assertions
#assert_kind_of
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/dm-core/query/path.rb', line 79
def method_missing(method, *args)
if @property
return @property.send(method, *args)
end
path_class = self.class
if relationship = @model.relationships(@repository_name)[method]
return path_class.new(@relationships.dup << relationship)
end
if @model.properties(@repository_name).named?(method)
return path_class.new(@relationships, method)
end
raise NoMethodError, "undefined property or relationship '#{method}' on #{@model}"
end
|
Instance Attribute Details
29
30
31
|
# File 'lib/dm-core/query/path.rb', line 29
def model
@model
end
|
32
33
34
|
# File 'lib/dm-core/query/path.rb', line 32
def property
@property
end
|
#relationships ⇒ Object
26
27
28
|
# File 'lib/dm-core/query/path.rb', line 26
def relationships
@relationships
end
|
#repository_name ⇒ Object
23
24
25
|
# File 'lib/dm-core/query/path.rb', line 23
def repository_name
@repository_name
end
|
Instance Method Details
#instance_of?(klass) ⇒ Boolean
49
50
51
|
# File 'lib/dm-core/query/path.rb', line 49
def instance_of?(klass)
super || (defined?(@property) ? @property.instance_of?(klass) : false)
end
|
#kind_of?(klass) ⇒ Boolean
44
45
46
|
# File 'lib/dm-core/query/path.rb', line 44
def kind_of?(klass)
super || (defined?(@property) ? @property.kind_of?(klass) : false)
end
|
#respond_to?(method, include_private = false) ⇒ Boolean
54
55
56
57
58
59
|
# File 'lib/dm-core/query/path.rb', line 54
def respond_to?(method, include_private = false)
super ||
(defined?(@property) && @property.respond_to?(method, include_private)) ||
@model.relationships(@repository_name).key?(method) ||
@model.properties(@repository_name).named?(method)
end
|