binarylogic / searchlogic

Searchlogic provides object based searching, common named scopes, and other useful tools.
http://rdoc.info/projects/binarylogic/searchlogic
MIT License
1.39k stars 133 forks source link

scope_procedure should send arguments if the options is a symbol #75

Open rainchen opened 14 years ago

rainchen commented 14 years ago

class User < ActiveRecord::Base scope_procedure :foo, :bar def self.bar(foo) end end

User.foo("bar") will raise arguments not matching error.

The issue code should be:

  def alias_scope(name, options = nil)
    alias_scopes[name.to_sym] = options
    (class << self; self end).instance_eval do
      define_method name do |*args|
        case options
        when Symbol
          send(options) # should be send(options, *args)
        else
          options.call(*args)
        end
      end
    end
  end