Class: Stockboy::MappedRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/stockboy/mapped_record.rb

Overview

This represents the “output” side of a CandidateRecord

Based on the current attribute map, it will have reader methods for the output values of each attribute. This is similar to an OpenStruct, but more efficient since we cache the defined methods.

Examples:

output = MappedRecord.new(first_name: "Zaphod")
output.first_name # => "Zaphod"

Direct Known Subclasses

SourceRecord

Instance Method Summary collapse

Constructor Details

#initialize(fields) ⇒ MappedRecord

Initialize a new MappedRecord

Parameters:

  • fields (Hash<Symbol>)

    Keys map to reader methods



45
46
47
48
49
50
# File 'lib/stockboy/mapped_record.rb', line 45

def initialize(fields)
  mod = AccessorMethods.for(fields.keys)
  extend mod
  @fields = fields
  freeze
end