Class: Mixpal::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/mixpal/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, properties) ⇒ Event

Returns a new instance of Event.



5
6
7
8
# File 'lib/mixpal/event.rb', line 5

def initialize(name, properties)
  @name = name
  @properties = properties
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/mixpal/event.rb', line 3

def name
  @name
end

#propertiesObject (readonly)

Returns the value of attribute properties.



3
4
5
# File 'lib/mixpal/event.rb', line 3

def properties
  @properties
end

Class Method Details

.from_store(data) ⇒ Object



22
23
24
# File 'lib/mixpal/event.rb', line 22

def self.from_store(data)
  new(data['name'], data['properties'])
end

Instance Method Details

#renderObject



10
11
12
13
# File 'lib/mixpal/event.rb', line 10

def render
  js_object = Mixpal::Util.hash_to_js_object_string(properties)
  "mixpanel.track(\"#{name}\", #{js_object});".html_safe
end

#to_storeObject



15
16
17
18
19
20
# File 'lib/mixpal/event.rb', line 15

def to_store
  {
    'name' => name,
    'properties' => properties
  }
end