Sha256: 67f48a66c22fd4704239219c808e8931cb127e0b5a3b560047f4b62a4b67661b

Contents?: true

Size: 506 Bytes

Versions: 8

Compression:

Stored size: 506 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

8 entries across 8 versions & 1 rubygems

Version Path
mixpal-0.5.0 lib/mixpal/event.rb
mixpal-0.4.2 lib/mixpal/event.rb
mixpal-0.4.1 lib/mixpal/event.rb
mixpal-0.4.0 lib/mixpal/event.rb
mixpal-0.3.0 lib/mixpal/event.rb
mixpal-0.2.1 lib/mixpal/event.rb
mixpal-0.2.0 lib/mixpal/event.rb
mixpal-0.1.0 lib/mixpal/event.rb