class Mixpal::User
Attributes
properties[R]
Public Class Methods
from_store(data)
click to toggle source
# File lib/mixpal/user.rb, line 19 def self.from_store(data) new(data['properties']) end
new(properties)
click to toggle source
# File lib/mixpal/user.rb, line 5 def initialize(properties) @properties = properties end
Public Instance Methods
render()
click to toggle source
# File lib/mixpal/user.rb, line 9 def render "mixpanel.people.set(#{properties_as_js_object_for_mixpanel});".html_safe end
to_store()
click to toggle source
# File lib/mixpal/user.rb, line 13 def to_store { 'properties' => properties } end
Private Instance Methods
mixpanel_special_properties_map()
click to toggle source
# File lib/mixpal/user.rb, line 37 def mixpanel_special_properties_map { name: '$name', email: '$email', created_at: '$created' }.with_indifferent_access end
properties_as_js_object_for_mixpanel()
click to toggle source
# File lib/mixpal/user.rb, line 25 def properties_as_js_object_for_mixpanel Mixpal::Util.hash_to_js_object_string(properties_for_mixpanel) end
properties_for_mixpanel()
click to toggle source
Isolate special properties and rename their keys to align with Mixpanel’s naming.
# File lib/mixpal/user.rb, line 31 def properties_for_mixpanel Hash[ properties.map { |k, v| [mixpanel_special_properties_map[k] || k, v] } ] end