Class: MySQL::Search::Source
- Inherits:
-
Object
- Object
- MySQL::Search::Source
- Defined in:
- lib/mysql/search/source.rb
Overview
Represents a source for search indexing.
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
- #extract ⇒ Object
-
#initialize(model) ⇒ Source
constructor
A new instance of Source.
Constructor Details
#initialize(model) ⇒ Source
Returns a new instance of Source.
30 31 32 |
# File 'lib/mysql/search/source.rb', line 30 def initialize(model) @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
11 12 13 |
# File 'lib/mysql/search/source.rb', line 11 def model @model end |
Class Method Details
.joins_args ⇒ Object
25 26 27 28 |
# File 'lib/mysql/search/source.rb', line 25 def self.joins_args combined_config = _config.values.reduce(&:deep_merge) extract_joins_args(combined_config) end |
.model ⇒ Object
21 22 23 |
# File 'lib/mysql/search/source.rb', line 21 def self.model _model || name.delete_suffix('Source').constantize end |
Instance Method Details
#extract ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/mysql/search/source.rb', line 34 def extract _config.each_with_object({}) do |(search_index_attribute, grabber_config), extracted| validate_search_index_attribute!(search_index_attribute) grabbed_data = Grabber.new(model, grabber_config).grab extracted[search_index_attribute] = grabbed_data.compact.join(' ').squish end end |