Sha256: 06ee6166358485e6a5002c513d1b449cb6ecff22358e75070a7027bd4c94338b
Contents?: true
Size: 984 Bytes
Versions: 10
Compression:
Stored size: 984 Bytes
Contents
require 'time' module Notifications class Client class Notification FIELDS = %i( id reference email_address phone_number line_1 line_2 line_3 line_4 line_5 line_6 postcode postage type status template body subject sent_at created_at completed_at created_by_name ).freeze attr_reader(*FIELDS) def initialize(notification) FIELDS.each do |field| instance_variable_set(:"@#{field}", notification.fetch(field.to_s, nil)) end end %i( sent_at created_at completed_at ).each do |field| define_method field do begin value = instance_variable_get(:"@#{field}") Time.parse value rescue StandardError value end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems