Class: ActiveMapper::Adapter::ActiveRecord::Query
- Inherits:
-
Object
- Object
- ActiveMapper::Adapter::ActiveRecord::Query
- Defined in:
- lib/active_mapper/adapter/active_record/query.rb,
lib/active_mapper/adapter/active_record/query/attribute.rb,
lib/active_mapper/adapter/active_record/query/expression.rb
Defined Under Namespace
Classes: AndExpression, Attribute, Expression, NotExpression, OrExpression
Instance Method Summary collapse
-
#initialize(table, &block) ⇒ Query
constructor
A new instance of Query.
- #method_missing(name, *args, &block) ⇒ Object
- #to_sql ⇒ Object
Constructor Details
#initialize(table, &block) ⇒ Query
Returns a new instance of Query.
8 9 10 11 |
# File 'lib/active_mapper/adapter/active_record/query.rb', line 8 def initialize(table, &block) @table = table @block = block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
17 18 19 |
# File 'lib/active_mapper/adapter/active_record/query.rb', line 17 def method_missing(name, *args, &block) Attribute.new(@table[name]) end |
Instance Method Details
#to_sql ⇒ Object
13 14 15 |
# File 'lib/active_mapper/adapter/active_record/query.rb', line 13 def to_sql @block ? @block.call(self).to_sql : {} end |