lib/cm_sms/webhook/response.rb in cm-sms-0.2.3 vs lib/cm_sms/webhook/response.rb in cm-sms-0.2.4

- old
+ new

@@ -2,13 +2,15 @@ module Webhook class Response ATTRIBUTE_NAMES = %w(sent received to reference statuscode errorcode errordescription) - attr_reader *ATTRIBUTE_NAMES + attr_reader *ATTRIBUTE_NAMES, :attributes def initialize(attributes = {}) + @attributes = attributes + attributes.each { |attr, value| instance_variable_set("@#{attr}", value) } if attributes end def sent? !sent.to_s.strip.empty? @@ -50,9 +52,13 @@ statuscode? && statuscode.to_s == '3' end def error? errorcode? || rejected? || failed? + end + + def to_yaml + (@attributes || {}).to_yaml end end end end \ No newline at end of file