class DataMapper::Query::Path
Attributes
model[R]
@api semipublic
property[R]
@api semipublic
relationships[R]
@api semipublic
repository_name[R]
@api semipublic
Public Class Methods
new(relationships, property_name = nil)
click to toggle source
@api semipublic
# File lib/dm-core/query/path.rb, line 80 def initialize(relationships, property_name = nil) @relationships = relationships.to_ary.dup last_relationship = @relationships.last @repository_name = last_relationship.relative_target_repository_name @model = last_relationship.target_model if property_name property_name = property_name.to_sym @property = @model.properties(@repository_name)[property_name] || raise(ArgumentError, "Unknown property '#{property_name}' in #{@model}") end end
Public Instance Methods
asc()
click to toggle source
Used for creating :order options. This technique may be deprecated, so marking as semipublic until the issue is resolved.
@api semipublic
# File lib/dm-core/query/path.rb, line 57 def asc Operator.new(property, :asc) end
desc()
click to toggle source
Used for creating :order options. This technique may be deprecated, so marking as semipublic until the issue is resolved.
@api semipublic
# File lib/dm-core/query/path.rb, line 65 def desc Operator.new(property, :desc) end
instance_of?(klass)
click to toggle source
@api public
Calls superclass method
# 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)
click to toggle source
@api public
Calls superclass method
# 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)
click to toggle source
@api semipublic
Calls superclass method
# File lib/dm-core/query/path.rb, line 70 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
Private Instance Methods
method_missing(method, *args)
click to toggle source
@api semipublic
# File lib/dm-core/query/path.rb, line 95 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