Module: Searchlogic::Search::Base
- Included in:
- Searchlogic::Search
- Defined in:
- lib/searchlogic/search/base.rb
Class Method Summary collapse
Instance Method Summary collapse
- #clone ⇒ Object
-
#initialize(klass, current_scope, conditions = {}) ⇒ Object
Creates a new search object for the given class.
Class Method Details
.included(klass) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/searchlogic/search/base.rb', line 4 def self.included(klass) klass.class_eval do attr_accessor :klass, :current_scope undef :id if respond_to?(:id) end end |
Instance Method Details
#clone ⇒ Object
21 22 23 |
# File 'lib/searchlogic/search/base.rb', line 21 def clone self.class.new(klass, current_scope && current_scope.clone, conditions.clone) end |
#initialize(klass, current_scope, conditions = {}) ⇒ Object
Creates a new search object for the given class. Ex:
Searchlogic::Search.new(User, {}, {:username_like => "bjohnson"})
14 15 16 17 18 19 |
# File 'lib/searchlogic/search/base.rb', line 14 def initialize(klass, current_scope, conditions = {}) self.klass = klass self.current_scope = current_scope @conditions ||= {} self.conditions = conditions if conditions.is_a?(Hash) end |