lib/intercom/traits/api_resource.rb in intercom-3.5.6 vs lib/intercom/traits/api_resource.rb in intercom-3.5.7
- old
+ new
@@ -65,11 +65,11 @@
def accessors_already_defined?(attribute)
respond_to?(attribute) && respond_to?("#{attribute}=")
end
def set_property(attribute, value)
- if typed_value?(value) && !custom_attribute_field?(attribute) && !message_from_field?(attribute, value) && !message_to_field?(attribute, value)
+ if typed_property?(attribute, value)
value_to_set = Intercom::Lib::TypedJsonDeserializer.new(value).deserialize
elsif flat_store_attribute?(attribute)
value_to_set = Intercom::Lib::FlatStore.new(value)
else
value_to_set = value
@@ -85,9 +85,17 @@
attribute.to_s == 'from' && value.is_a?(Hash) && value['type']
end
def message_to_field?(attribute, value)
attribute.to_s == 'to' && value.is_a?(Hash) && value['type']
+ end
+
+ def typed_property?(attribute, value)
+ typed_value?(value) &&
+ !custom_attribute_field?(attribute) &&
+ !message_from_field?(attribute, value) &&
+ !message_to_field?(attribute, value) &&
+ attribute != 'metadata'
end
def typed_value?(value)
value.is_a? Hash and !!value['type']
end