Created
October 14, 2008 20:01
-
-
Save fizx/16781 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
# Allows usage of the following syntax: | |
# Model.find :conditions => {:field => NotNull} | |
class NotNullClass | |
def map(*a, &b) | |
[].map(*a, &b) | |
end | |
def empty? | |
true | |
end | |
end | |
NotNull = NotNullClass.new | |
module ActiveRecord | |
class Base | |
class << self | |
def attribute_condition_with_not_null(argument) | |
case argument | |
when NotNullClass then "IS NOT ?" | |
else | |
attribute_condition_without_not_null(argument) | |
end | |
end | |
alias_method_chain :attribute_condition, :not_null | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment