Module: ActiveRecord::Acts::Searchable::ActMethods
- Defined in:
- lib/acts_as_searchable.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#changed?(attr_name = nil) ⇒ Boolean
If called with no parameters, gets whether the current model has changed and needs to updated in the index.
-
#estraier_doc ⇒ Object
Retrieve index record for current model object.
-
#update_index(force = false) ⇒ Object
Update index for current instance.
Class Method Details
.included(base) ⇒ Object
:nodoc:
248 249 250 |
# File 'lib/acts_as_searchable.rb', line 248 def self.included(base) #:nodoc: base.extend ClassMethods end |
Instance Method Details
#changed?(attr_name = nil) ⇒ Boolean
If called with no parameters, gets whether the current model has changed and needs to updated in the index. If called with a single parameter, gets whether the parameter has changed.
271 272 273 274 |
# File 'lib/acts_as_searchable.rb', line 271 def changed?(attr_name = nil) changed_attributes and (attr_name.nil? ? (not changed_attributes.length.zero?) : (changed_attributes.include?(attr_name.to_s)) ) end |
#estraier_doc ⇒ Object
Retrieve index record for current model object
260 261 262 263 264 265 266 267 |
# File 'lib/acts_as_searchable.rb', line 260 def estraier_doc cond = EstraierPure::Condition::new cond.add_attr("db_id STREQ #{self.id}") cond.add_attr("type STREQ #{self.class.to_s}") result = self.estraier_connection.search(cond, 1) return unless result and result.doc_num > 0 get_doc_from(result) end |
#update_index(force = false) ⇒ Object
Update index for current instance
253 254 255 256 257 |
# File 'lib/acts_as_searchable.rb', line 253 def update_index(force = false) return unless changed? or force remove_from_index add_to_index end |