Class: Blueprinter::BlockExtractor Private
- Defined in:
- lib/blueprinter/extractors/block_extractor.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
Methods inherited from Extractor
Instance Method Details
#extract(_field_name, object, local_options, options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/blueprinter/extractors/block_extractor.rb', line 8 def extract(_field_name, object, , = {}) block = [:block] # Symbol#to_proc creates procs with signature [[:req], [:rest]] # These procs forward ALL arguments to the method, which causes # issues when we call block.call(object, local_options) because # it becomes object.method_name(local_options), and most methods # don't accept extra arguments. # # For Symbol#to_proc, we only pass the object. # For regular blocks, we pass both object and local_options. if symbol_to_proc?(block) block.call(object) else block.call(object, **) end end |