29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/vero/trackable/base.rb', line 29
def to_vero
klass = self.class
symbols, other = klass.trackable_map.partition { |i| i.is_a?(Symbol) }
result = symbols.each_with_object({}) do |symbol, hash|
t = respond_to?(symbol) ? send(symbol) : nil
hash[symbol] = t unless t.nil?
end
if other.is_a?(Array) && !other.empty?
other.select! { |i| (i.is_a?(Hash) && i.key?(:extras)) }
other.each do |h|
symbol = h[:extras]
t = respond_to?(symbol, true) ? send(symbol) : nil
result.merge!(t) if t.is_a?(Hash)
end
end
result[:email] = result.delete(:email_address) if result.key?(:email_address)
result[:_user_type] = self.class.name
result
end
|