Module: RQuery::ActiveRecord

Defined in:
lib/rquery/active_record/base.rb

Instance Method Summary collapse

Instance Method Details

#where(*args) {|collector| ... } ⇒ Object

Yields:

  • (collector)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rquery/active_record/base.rb', line 3

def where(*args, &block)
  collector = RQuery::AttributeCollection.new(self.new.attribute_names)
  
  #Passes a new AttributeCollection object to the block
  #if RQuery.use_symbols has been called it may not be used
  #but otherwise will take the form attr_coll_object.attribute.is ...
  yield(collector)

  #record altered conditions and values
  conditions = collector.clauses.to_conditions

  #limit the records returned (:first, :all, :last)
  limit = args.first ? args.first : :all

  #call find with the conditions and values provided by the block
  find(limit, :conditions => conditions)
end