From aa38e79c3b46f04f6ee6ee0aca7d92d7babb3bbc Mon Sep 17 00:00:00 2001 From: Sean Walbran Date: Thu, 2 May 2013 10:26:43 -0500 Subject: [PATCH] use lambda to meet rails4 requirement that scopes respond to call --- lib/attr_enumerator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/attr_enumerator.rb b/lib/attr_enumerator.rb index 4068401..6faf4c1 100644 --- a/lib/attr_enumerator.rb +++ b/lib/attr_enumerator.rb @@ -9,14 +9,14 @@ def attr_enumerator(attribute, choices, options = {}) constant = options.delete(:constant) || attribute.to_s.pluralize.upcase prefix = options[:prefix] ? options.delete(:prefix).to_s + '_' : '' options[:message] ||= :invalid - + const_set(constant, choices).freeze validates_inclusion_of attribute, options.merge(:in => choices) choices.each do |choice| choice_string = prefix + choice.to_s.underscore.parameterize('_') define_method(choice_string + '?') { send(attribute) == choice } - scope choice_string, where(attribute => choice) if respond_to? :scope + scope choice_string, lambda { where(attribute => choice) } if respond_to? :scope end end end