class Parse::Event

Attributes

event_class_name[RW]
parse_client[RW]
at[RW]
dimensions[RW]

Public Class Methods

create(event_class_name, mod=::Object) click to toggle source
# File lib/parse/event.rb, line 20
def create event_class_name, mod=::Object
  raise 'already defined' if mod.const_defined? event_class_name

  if RESERVED_EVENT_CLASS.has_key? event_class_name.to_s
    eval RESERVED_EVENT_CLASS[event_class_name.to_s]
  else
    klass = Class.new(Parse::Event)
    klass.event_class_name = event_class_name.to_sym
    mod.const_set event_class_name, klass
    register_event_class klass
  end
end
fire(hash={}) click to toggle source
# File lib/parse/event.rb, line 41
def fire hash={}
  self.new(hash).fire
end
new(hash={}) click to toggle source
# File lib/parse/event.rb, line 48
def initialize hash={}
  hash = string_keyed_hash hash
  @at = hash.delete 'at'
  @at = ParseDate.parse @at if @at.is_a?(String)
  @dimensions = hash.dup
end
register_event_class(event_class) click to toggle source
# File lib/parse/event.rb, line 16
def register_event_class event_class
  @@event_class_vs_class_table[event_class.event_class_name] = event_class
end

Public Instance Methods

event_class_name() click to toggle source
# File lib/parse/event.rb, line 65
def event_class_name
  self.class.event_class_name
end
fire() click to toggle source
# File lib/parse/event.rb, line 55
def fire
  body = @dimensions
  body['at'] = @at if @at
  parse_client.call_api :post, "events/#{event_class_name}", body.to_json
end
parse_client() click to toggle source
# File lib/parse/event.rb, line 61
def parse_client
  self.class.parse_client
end