Class: Sunspot::DataExtractor::BlockExtractor
- Inherits:
-
Object
- Object
- 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.
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.
28 29 30 |
# File 'lib/sunspot/data_extractor.rb', line 28 def initialize(&block) @block = block end |
Instance Method Details
#value_for(object) ⇒ Object
32 33 34 |
# File 'lib/sunspot/data_extractor.rb', line 32 def value_for(object) Util.instance_eval_or_call(object, &@block) end |