Sha256: 2f55790fa56f46e1fa9f03932c87a2c42d162d5ebb1d3134d49255ab0d2a0b07

Contents?: true

Size: 496 Bytes

Versions: 2

Compression:

Stored size: 496 Bytes

Contents

module Mixpal
  class Event
    attr_reader :name, :properties

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

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

    def to_store
      {
        name: name,
        properties: properties,
      }
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mixpal-0.0.5 lib/mixpal/event.rb
mixpal-0.0.4 lib/mixpal/event.rb