Skip to content
Browse files

Remove deprecation warning.

  • Loading branch information...
1 parent 50ec2c7 commit 0beb5d573f41315607bb6f98a37ddff968784ab1 @josevalim josevalim committed Jan 20, 2010
Showing with 7 additions and 9 deletions.
  1. +7 −9 lib/has_scope.rb
View
16 lib/has_scope.rb
@@ -14,7 +14,6 @@ def self.included(base)
helper_method :current_scopes
class_inheritable_hash :scopes_configuration, :instance_writer => false
- self.scopes_configuration ||= {}
end
end
@@ -64,14 +63,11 @@ def has_scope(*scopes, &block)
options = scopes.extract_options!
options.symbolize_keys!
- if options.delete(:boolean)
- options[:type] ||= :boolean
- ActiveSupport::Deprecation.warn(":boolean => true is deprecated, use :type => :boolean instead", caller)
- end
options.assert_valid_keys(:type, :only, :except, :if, :unless, :default, :as, :allow_blank)
options[:only] = Array(options[:only])
options[:except] = Array(options[:except])
+ self.scopes_configuration ||= {}
scopes.each do |scope|
self.scopes_configuration[scope] ||= { :as => scope, :type => :default, :block => block }
@@ -119,18 +115,20 @@ def set_current_scope(type, key, value) #:nodoc:
if type == :boolean
current_scopes[key] = TRUE_VALUES.include?(value)
elsif ALLOWED_TYPES[type].none?{ |klass| value.is_a?(klass) }
- raise "Expected type :#{type} in params[:#{key}], got :#{value.class}"
+ raise "Expected type :#{type} in params[:#{key}], got #{value.class}"
else
current_scopes[key] = value
end
end
# Apply the scope taking into account its type.
def apply_scope_by_type(type, scope, target, value, block) #:nodoc:
- return target if type == :boolean && value == false
-
if type == :boolean
- block ? block.call(self, target) : target.send(scope)
+ if value
+ block ? block.call(self, target) : target.send(scope)
+ else
+ target
+ end
else
block ? block.call(self, target, value) : target.send(scope, value)
end

0 comments on commit 0beb5d5

Please sign in to comment.
Something went wrong with that request. Please try again.