Class: DataMapper::Query::Path
- Includes:
- Assertions
- Defined in:
- lib/gems/dm-core-0.9.9/lib/dm-core/query.rb
Overview
class Operator
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#relationships ⇒ Object
readonly
Returns the value of attribute relationships.
Instance Method Summary collapse
-
#field(*args) ⇒ Object
duck type the DM::Query::Path to act like a DM::Property.
-
#to_sym ⇒ Object
more duck typing.
Methods included from Assertions
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
661 662 663 664 665 666 667 668 669 670 671 672 673 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/query.rb', line 661 def method_missing(method, *args) if relationship = @model.relationships(@repository.name)[method] klass = klass = model == relationship.child_model ? relationship.parent_model : relationship.child_model return Query::Path.new(@repository, @relationships + [ relationship ], klass) end if @model.properties(@repository.name)[method] @property = @model.properties(@repository.name)[method] unless @property return self end raise NoMethodError, "undefined property or association `#{method}' on #{@model}" end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
627 628 629 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/query.rb', line 627 def model @model end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
627 628 629 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/query.rb', line 627 def operator @operator end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
627 628 629 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/query.rb', line 627 def property @property end |
#relationships ⇒ Object (readonly)
Returns the value of attribute relationships.
627 628 629 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/query.rb', line 627 def relationships @relationships end |
Instance Method Details
#field(*args) ⇒ Object
duck type the DM::Query::Path to act like a DM::Property
638 639 640 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/query.rb', line 638 def field(*args) @property ? @property.field(*args) : nil end |
#to_sym ⇒ Object
more duck typing
643 644 645 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/query.rb', line 643 def to_sym @property ? @property.name.to_sym : @model.storage_name(@repository).to_sym end |