lib/intercom-rails/proxy.rb in intercom-rails-0.2.24 vs lib/intercom-rails/proxy.rb in intercom-rails-0.2.25
- old
+ new
@@ -8,11 +8,11 @@
self.to_s.split('::').last
end
def self.inherited(subclass)
subclass.class_eval do
- attr_reader class_string.downcase.to_s
+ attr_reader class_string.downcase.to_s
end
end
attr_reader :search_object, :proxied_object
@@ -21,10 +21,15 @@
@proxied_object = instance_variable_set(:"@#{type}", object_to_proxy)
end
def to_hash
data = standard_data.merge(custom_data)
+ [:id, :user_id].each do |id_key|
+ if(data[id_key] && !data[id_key].is_a?(Numeric))
+ data[id_key] = data[id_key].to_s
+ end
+ end
DateHelper.convert_dates_to_unix_timestamps(data)
end
def standard_data
proxied_values = self.class.standard_data_proxy_attributes.reduce({}) do |hsh, attribute_name|
@@ -74,11 +79,11 @@
instance_variable_name = :"@_proxy_#{attribute_name}_delegated_value"
standard_data_proxy_attributes << attribute_name
identity_attributes << attribute_name if options[:identity]
send(:define_method, attribute_name) do
- return nil unless proxied_object.respond_to?(attribute_name)
+ return nil unless proxied_object.respond_to?(attribute_name)
current_value = instance_variable_get(instance_variable_name)
return current_value if current_value
value = proxied_object.send(attribute_name)
@@ -114,16 +119,16 @@
@_standard_data_config_attributes ||= []
end
private
- def custom_data_from_request
+ def custom_data_from_request
search_object.intercom_custom_data.send(type)
rescue NoMethodError
{}
end
- def custom_data_from_config
+ def custom_data_from_config
return {} if config.custom_data.blank?
config.custom_data.reduce({}) do |custom_data, (k,v)|
custom_data.merge(k => custom_data_value_from_proc_or_symbol(v))
end
end