Skip to content

Instantly share code, notes, and snippets.

@johnbender
Created March 17, 2009 03:48
Show Gist options
  • Save johnbender/80267 to your computer and use it in GitHub Desktop.
Save johnbender/80267 to your computer and use it in GitHub Desktop.
module ActiveRecord
class Base
def Base.where(*args, &block)
#yielding the block will alter the Operations class
yield
#record altered conditions and values
conditions = ::RedQuery::Serializers::Operations.to_sql
values = ::RedQuery::Serializers::Operations.values
#clear the alterations
::RedQuery::Serializers::Operations.clear
#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, values])
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment