Class: Event

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
CommonScopes
Defined in:
app/models/event.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CommonScopes

included

Class Method Details

.record_event(event_hash) ⇒ Object

event_hash = => “Event Type”, :message => “Event Message”, :organization => Current Obj Org ID, :uuid => “Record UUID”, :animal => animal.id


15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/event.rb', line 15

def self.record_event(event_hash)
  @event = Event.new
  @event.animal_id = event_hash[:animal].to_i
  @event.update_attributes(:organization_id => event_hash[:organization].to_i,
    :event_type => "#{event_hash[:type]}", 
    :event_message => "#{event_hash[:message]}",
    :record_uuid => event_hash[:uuid],
    :related_model_id => event_hash.try(:[], :related_id),
    :related_model_name => event_hash.try(:[], :related_name)
    )
  @event
end

Instance Method Details

#increment_statsObject


10
11
12
# File 'app/models/event.rb', line 10

def increment_stats
  $statsd.increment 'event.created'
end