Sha256: a0d1ad599a1f118e2b426ae3af4b29bd26e862ef5927ead90c6fc1acb82c2411
Contents?: true
Size: 944 Bytes
Versions: 3
Compression:
Stored size: 944 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 type status template body subject sent_at created_at completed_at ).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
3 entries across 3 versions & 1 rubygems