Class: Mixpal::Revenue

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount, properties) ⇒ Revenue

Returns a new instance of Revenue.



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

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

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



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

def amount
  @amount
end

#propertiesObject (readonly)

Returns the value of attribute properties.



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

def properties
  @properties
end

Class Method Details

.from_store(data) ⇒ Object



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

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

Instance Method Details

#renderObject



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

def render
  args = "#{amount}, #{properties_as_js_object_for_mixpanel}"
  "mixpanel.people.track_charge(#{args});".html_safe
end

#to_storeObject



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

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