Class: MultipleMan::AttributeExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/multiple_man/attribute_extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(record, fields, include_previous = false) ⇒ AttributeExtractor

Returns a new instance of AttributeExtractor.



6
7
8
9
10
11
12
# File 'lib/multiple_man/attribute_extractor.rb', line 6

def initialize(record, fields, include_previous = false)
  raise "Fields must be specified" unless fields

  self.include_previous = include_previous
  self.record = record
  self.fields = fields
end

Instance Method Details

#as_jsonObject



14
15
16
17
18
19
20
# File 'lib/multiple_man/attribute_extractor.rb', line 14

def as_json
  if include_previous
    data.merge({previous: data("_was")})
  else
    data
  end
end