Class: DataMapper::Query::Path
- Inherits:
-
Object
- Object
- DataMapper::Query::Path
show all
- Extended by:
- Equalizer
- Includes:
- Assertions
- Defined in:
- lib/dm-core/query/path.rb
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
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/dm-core/query/path.rb', line 98
private def method_missing(method, *args)
return @property.send(method, *args) if @property
path_class = self.class
if (relationship = @model.relationships(@repository_name)[method])
return path_class.new(@relationships.dup << relationship)
end
return path_class.new(@relationships, method) if @model.properties(@repository_name).named?(method)
raise NoMethodError, "undefined property or relationship '#{method}' on #{@model}"
end
|
Instance Attribute Details
#model ⇒ Object
32
33
34
|
# File 'lib/dm-core/query/path.rb', line 32
def model
@model
end
|
#property ⇒ Object
35
36
37
|
# File 'lib/dm-core/query/path.rb', line 35
def property
@property
end
|
#relationships ⇒ Object
29
30
31
|
# File 'lib/dm-core/query/path.rb', line 29
def relationships
@relationships
end
|
#repository_name ⇒ Object
26
27
28
|
# File 'lib/dm-core/query/path.rb', line 26
def repository_name
@repository_name
end
|
Instance Method Details
#asc ⇒ Object
Used for creating :order options. This technique may be deprecated, so marking as semipublic until the issue is resolved.
62
63
64
|
# File 'lib/dm-core/query/path.rb', line 62
def asc
Operator.new(property, :asc)
end
|
#desc ⇒ Object
Used for creating :order options. This technique may be deprecated, so marking as semipublic until the issue is resolved.
70
71
72
|
# File 'lib/dm-core/query/path.rb', line 70
def desc
Operator.new(property, :desc)
end
|
#instance_of?(klass) ⇒ Boolean
54
55
56
|
# File 'lib/dm-core/query/path.rb', line 54
def instance_of?(klass)
super || (defined?(@property) ? @property.instance_of?(klass) : false)
end
|
#kind_of?(klass) ⇒ Boolean
49
50
51
|
# File 'lib/dm-core/query/path.rb', line 49
def kind_of?(klass)
super || (defined?(@property) ? @property.is_a?(klass) : false)
end
|
#respond_to?(method, include_private = false) ⇒ Boolean
75
76
77
78
79
80
|
# File 'lib/dm-core/query/path.rb', line 75
def respond_to?(method, include_private = false)
super ||
(defined?(@property) && @property.respond_to?(method, include_private)) ||
@model.relationships(@repository_name).named?(method) ||
@model.properties(@repository_name).named?(method)
end
|