Created
March 17, 2009 03:48
-
-
Save johnbender/80267 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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