Class: Stockboy::SourceRecord

Inherits:
MappedRecord show all
Defined in:
lib/stockboy/source_record.rb

Overview

This represents the raw “input” side of a CandidateRecord

It provides access to the original field values before mapping or translation as hash keys.

Examples:

input = SourceRecord.new(
    {check_in: "2012-12-12"},
    {"RawCheckIn" => "2012-12-12"})

input["RawCheckIn"] # => "2012-12-12"
input.check_in # => "2012-12-12"

Instance Method Summary collapse

Constructor Details

#initialize(mapped_fields, data_fields) ⇒ SourceRecord

Initialize a new instance

Parameters:

  • mapped_fields (Hash{Symbol=>Object})

    Represents the raw values mapped to the final attribute names

  • data_fields (Hash)

    The raw input fields with original key values



27
28
29
30
# File 'lib/stockboy/source_record.rb', line 27

def initialize(mapped_fields, data_fields)
  @data_fields = data_fields
  super(mapped_fields)
end

Instance Method Details

#[](key) ⇒ Object

Access a raw field value by the original input field name

Parameters:

  • key (String)


36
37
38
39
# File 'lib/stockboy/source_record.rb', line 36

def [](key)
  key = key.to_s if key.is_a? Symbol
  @data_fields[key]
end