Class: ActiveMapper::Adapter::ActiveRecord::Query

Inherits:
Object
  • Object
show all
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

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_sqlObject



13
14
15
# File 'lib/active_mapper/adapter/active_record/query.rb', line 13

def to_sql
  @block ? @block.call(self).to_sql : {}
end