Module: Pose::ModelClassAdditions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/pose/model_class_additions.rb
Instance Method Summary collapse
-
#delete_pose_index ⇒ Object
Removes this objects from the search index.
-
#pose_current_words ⇒ Array<String>
Returns all words in the search index for this instance.
-
#pose_fetch_content ⇒ String
Returns the searchable text snippet for this instance.
- #pose_fresh_words(reload = false) ⇒ Array<String>
- #pose_stale_words(reload = false) ⇒ Array<String>
- #pose_words_to_add(reload = false) ⇒ Array<String>
-
#update_pose_index ⇒ Object
Updates the associated words for this object in the database.
-
#update_pose_words ⇒ Object
Helper method.
Instance Method Details
#delete_pose_index ⇒ Object
Removes this objects from the search index.
52 53 54 |
# File 'lib/pose/model_class_additions.rb', line 52 def delete_pose_index self.pose_words.clear if Pose.perform_search? end |
#pose_current_words ⇒ Array<String>
Returns all words in the search index for this instance.
18 19 20 |
# File 'lib/pose/model_class_additions.rb', line 18 def pose_current_words pose_words.map(&:text) end |
#pose_fetch_content ⇒ String
Returns the searchable text snippet for this instance. This data is not stored in the search engine. It is recomputes this from data in the database here.
26 27 28 |
# File 'lib/pose/model_class_additions.rb', line 26 def pose_fetch_content instance_eval(&(pose_content)).to_s end |
#pose_fresh_words(reload = false) ⇒ Array<String>
31 32 33 34 |
# File 'lib/pose/model_class_additions.rb', line 31 def pose_fresh_words reload = false @pose_fresh_words = nil if reload @pose_fresh_words ||= Query.query_words pose_fetch_content end |
#pose_stale_words(reload = false) ⇒ Array<String>
37 38 39 |
# File 'lib/pose/model_class_additions.rb', line 37 def pose_stale_words reload = false pose_current_words - pose_fresh_words(reload) end |
#pose_words_to_add(reload = false) ⇒ Array<String>
42 43 44 |
# File 'lib/pose/model_class_additions.rb', line 42 def pose_words_to_add reload = false pose_fresh_words(reload) - pose_current_words end |
#update_pose_index ⇒ Object
Updates the associated words for this object in the database.
47 48 49 |
# File 'lib/pose/model_class_additions.rb', line 47 def update_pose_index update_pose_words if Pose.perform_search? end |
#update_pose_words ⇒ Object
Helper method. Updates the search words with the text returned by search_strings.
58 59 60 61 |
# File 'lib/pose/model_class_additions.rb', line 58 def update_pose_words self.pose_words.delete(Word.factory(pose_stale_words true)) self.pose_words << Word.factory(pose_words_to_add) end |