Class: MySQL::Search::Grabber
- Inherits:
-
Object
- Object
- MySQL::Search::Grabber
- Defined in:
- lib/mysql/search/grabber.rb
Overview
Extracts and formats data for search indexing.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #grab ⇒ Object
-
#initialize(model, config) ⇒ Grabber
constructor
A new instance of Grabber.
Constructor Details
#initialize(model, config) ⇒ Grabber
Returns a new instance of Grabber.
9 10 11 12 |
# File 'lib/mysql/search/grabber.rb', line 9 def initialize(model, config) @model = model @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/mysql/search/grabber.rb', line 7 def config @config end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/mysql/search/grabber.rb', line 7 def model @model end |
Instance Method Details
#grab ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mysql/search/grabber.rb', line 14 def grab config.flat_map do |attr_or_relation, format_or_config| case format_or_config when Hash then forward(attr_or_relation, format_or_config) when Symbol, String, Array, Proc then format(attr_or_relation, format_or_config) else raise(ArgumentError, "unknown config value: '#{format_or_config.inspect}'") end end end |