def has_scope(*scopes, &block)
      options = scopes.extract_options!
      options.symbolize_keys!
      options.assert_valid_keys(:type, :only, :except, :if, :unless, :default, :as, :using, :allow_blank, :in)

      if options.key?(:in)
        options[:as] = options[:in]
        options[:using] = scopes
      end

      if options.key?(:using)
        if options.key?(:type) && options[:type] != :hash
          raise "You cannot use :using with another :type different than :hash"
        else
          options[:type] = :hash
        end

        options[:using] = Array(options[:using])
      end

      options[:only]   = Array(options[:only])
      options[:except] = Array(options[:except])

      self.scopes_configuration = scopes_configuration.dup

      scopes.each do |scope|
        scopes_configuration[scope] ||= { :as => scope, :type => :default, :block => block }
        scopes_configuration[scope] = self.scopes_configuration[scope].merge(options)
      end
    end
def has_scope(*scopes, &block)
      options = scopes.extract_options!
      options.symbolize_keys!
      options.assert_valid_keys(:type, :only, :except, :if, :unless, :default, :as, :using, :allow_blank, :in)

      if options.key?(:in)
        options[:as] = options[:in]
        options[:using] = scopes
      end

      if options.key?(:using)
        if options.key?(:type) && options[:type] != :hash
          raise "You cannot use :using with another :type different than :hash"
        else
          options[:type] = :hash
        end

        options[:using] = Array(options[:using])
      end

      options[:only]   = Array(options[:only])
      options[:except] = Array(options[:except])

      self.scopes_configuration = scopes_configuration.dup

      scopes.each do |scope|
        scopes_configuration[scope] ||= { :as => scope, :type => :default, :block => block }
        scopes_configuration[scope] = self.scopes_configuration[scope].merge(options)
      end
    end
Detects params from url and apply as scopes to your classes.

 == Options

 * <tt>:type</tt> - Checks the type of the parameter sent. If set to :boolean
                    it just calls the named scope, without any argument. By default,
                    it does not allow hashes or arrays to be given, except if type
                    :hash or :array are set.

 * <tt>:only</tt> - In which actions the scope is applied. By default is :all.

 * <tt>:except</tt> - In which actions the scope is not applied. By default is :none.

 * <tt>:as</tt> - The key in the params hash expected to find the scope.
                  Defaults to the scope name.

 * <tt>:using</tt> - If type is a hash, you can provide :using to convert the hash to
                     a named scope call with several arguments.

 * <tt>:if</tt> - Specifies a method, proc or string to call to determine
                  if the scope should apply

 * <tt>:unless</tt> - Specifies a method, proc or string to call to determine
                      if the scope should NOT apply.

 * <tt>:default</tt> - Default value for the scope. Whenever supplied the scope
                       is always called.

 * <tt>:allow_blank</tt> - Blank values are not sent to scopes by default. Set to true to overwrite.

 == Block usage

 has_scope also accepts a block. The controller, current scope and value are yielded
 to the block so the user can apply the scope on its own. This is useful in case we
 need to manipulate the given value:

   has_scope :category do |controller, scope, value|
     value != "all" ? scope.by_category(value) : scope
   end

   has_scope :not_voted_by_me, :type => :boolean do |controller, scope|
     scope.not_voted_by(controller.current_user.id)
   end