class NCUA::CreditUnion::Record

Attributes

attributes[R]

Public Class Methods

date_field(method_name, response_key=method_name) click to toggle source
# File lib/ncua/credit_union/record.rb, line 27
def self.date_field(method_name, response_key=method_name)
  field(method_name, response_key) { |value|
    Date.parse(value)
  }
end
field(method_name, response_key=method_name, &munger) click to toggle source
# File lib/ncua/credit_union/record.rb, line 11
def self.field(method_name, response_key=method_name, &munger)
  munger ||= lambda { |x| x }
  define_method(method_name) {
    if response_key.is_a? Symbol
      value = attributes[response_key]
    else
      value = attributes[response_key.to_s]
    end
    value && munger.call(value)
  }
end
int_field(method_name, response_key=method_name) click to toggle source
# File lib/ncua/credit_union/record.rb, line 23
def self.int_field(method_name, response_key=method_name)
  field(method_name, response_key, &:to_i)
end
new(attributes) click to toggle source
# File lib/ncua/credit_union/record.rb, line 4
def initialize(attributes)
  @attributes = attributes
  @attributes.freeze
end