Class: Blueprinter::AutoExtractor Private

Inherits:
Extractor
  • Object
show all
Includes:
EmptyTypes
Defined in:
lib/blueprinter/extractors/auto_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

extract

Constructor Details

#initializeAutoExtractor

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.

Returns a new instance of AutoExtractor.



15
16
17
18
19
20
# File 'lib/blueprinter/extractors/auto_extractor.rb', line 15

def initialize
  @hash_extractor = HashExtractor.new
  @public_send_extractor = PublicSendExtractor.new
  @block_extractor = BlockExtractor.new
  @datetime_formatter = DateTimeFormatter.new
end

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.



22
23
24
25
26
# File 'lib/blueprinter/extractors/auto_extractor.rb', line 22

def extract(field_name, object, local_options, options = {})
  extraction = extractor(object, options).extract(field_name, object, local_options, options)
  value = @datetime_formatter.format(extraction, options)
  use_default_value?(value, options[:default_if]) ? default_value(options) : value
end