Class: Blueprinter::AutoExtractor

Inherits:
Extractor
  • Object
show all
Defined in:
lib/blueprinter/extractors/auto_extractor.rb

Instance Method Summary collapse

Methods inherited from Extractor

extract

Constructor Details

#initializeAutoExtractor

Returns a new instance of AutoExtractor.



3
4
5
6
7
8
# File 'lib/blueprinter/extractors/auto_extractor.rb', line 3

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



10
11
12
13
14
# File 'lib/blueprinter/extractors/auto_extractor.rb', line 10

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)
  value.nil? ? default_value(options) : value
end