Sha256: 46f9bee868239eef505dbe0580e01ae8c6ccdf8e62ce57bdfdb9483477f32182
Contents?: true
Size: 887 Bytes
Versions: 1
Compression:
Stored size: 887 Bytes
Contents
module FDIC class Record def initialize(attributes) @attributes = attributes @attributes.freeze end attr_reader :attributes def self.field(method_name, response_key=method_name, &munger) munger ||= lambda { |x| x } define_method(method_name) { value = attributes[response_key.to_s] value && munger.call(value) } end def self.int_field(method_name, response_key=method_name) field(method_name, response_key, &:to_i) end def self.currency_field(method_name, response_key=method_name) field(method_name, response_key) { |value| value.to_f * 1000 } end def self.date_field(method_name, response_key=method_name) field(method_name, response_key) { |value| Date.parse(value) } end def uri attributes['__metadata']['uri'] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fdic-0.3.0 | lib/fdic/record.rb |