Created
January 14, 2011 09:55
-
-
Save pechorin/779429 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
yes_no_conditions_creator = lambda {|yes_or_no,field_name| | |
if yes_or_no == 'yes' | |
{:conditions => "books.#{field_name.to_s} = true"} | |
elsif yes_or_no == 'no' | |
{:conditions => "books.#{field_name.to_s} = false or books.#{field_name.to_s} is null"} | |
else | |
{} | |
end | |
} | |
named_scope :by_period_assigned, lambda {|yes_or_no| yes_no_conditions_creator.call(yes_or_no, :period_assigned)} | |
named_scope :by_priority_assigned, lambda {|yes_or_no| yes_no_conditions_creator.call(yes_or_no, :priority_assigned)} | |
named_scope :by_is_technically_copied, lambda {|yes_or_no| yes_no_conditions_creator.call(yes_or_no, :is_technically_copied)} | |
named_scope :by_verification_completed, lambda {|yes_or_no| yes_no_conditions_creator.call(yes_or_no, :verification_completed)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment