Class: Blueprinter::AutoExtractor
- Defined in:
- lib/blueprinter/extractors/auto_extractor.rb
Instance Method Summary collapse
- #extract(field_name, object, local_options, options = {}) ⇒ Object
-
#initialize ⇒ AutoExtractor
constructor
A new instance of AutoExtractor.
Methods inherited from Extractor
Constructor Details
#initialize ⇒ AutoExtractor
Returns a new instance of AutoExtractor.
3 4 5 6 7 |
# File 'lib/blueprinter/extractors/auto_extractor.rb', line 3 def initialize @hash_extractor = HashExtractor.new @public_send_extractor = PublicSendExtractor.new @block_extractor = BlockExtractor.new end |
Instance Method Details
#extract(field_name, object, local_options, options = {}) ⇒ Object
9 10 11 12 13 |
# File 'lib/blueprinter/extractors/auto_extractor.rb', line 9 def extract(field_name, object, , = {}) extraction = extractor(object, ).extract(field_name, object, , ) value = .key?(:datetime_format) ? format_datetime(extraction, [:datetime_format]) : extraction value.nil? ? default_value() : value end |