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

Support for scope return by model class method #77

Open speedmax opened 14 years ago

speedmax commented 14 years ago

is there any chance that searchlogic will support class method that returns a scope or ActiveRecord::Relation.

They both support chainable lazily queries, this is better to construct more complex name scopes that has parameters, (default param value in a lambda is pain between Ruby 1.8/1.9)

example

# Rails 2
class Task < ActiveRecord::Base
  # scopes
  def self.completed
    scoped(:conditions => {:status => 'completed'})
  end
end

# Rails 3
class Task < ActiveRecord::Base
  # scopes
  def self.completed
    where(:status => 'completed')
  end
end