Class: Sunspot::DataExtractor::BlockExtractor
- Inherits:
-
AbstractExtractor
- Object
- AbstractExtractor
- Sunspot::DataExtractor::BlockExtractor
- Defined in:
- lib/sunspot/data_extractor.rb
Overview
BlockExtractors extract data by evaluating a block in the context of the object instance, or if the block takes an argument, by passing the object as the argument to the block. Either way, the return value of the block is the value returned by the extractor.
Constant Summary
Constants inherited from AbstractExtractor
AbstractExtractor::BLACKLIST_REGEXP
Instance Method Summary collapse
-
#initialize(&block) ⇒ BlockExtractor
constructor
A new instance of BlockExtractor.
- #value_for(object) ⇒ Object
Constructor Details
#initialize(&block) ⇒ BlockExtractor
Returns a new instance of BlockExtractor.
58 59 60 |
# File 'lib/sunspot/data_extractor.rb', line 58 def initialize(&block) @block = block end |
Instance Method Details
#value_for(object) ⇒ Object
62 63 64 |
# File 'lib/sunspot/data_extractor.rb', line 62 def value_for(object) super Util.instance_eval_or_call(object, &@block) end |