Class: ActiveWorker::Event

Inherits:
Object
  • Object
show all
Includes:
Behavior::HasRootObject, Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/active_worker/event.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Behavior::HasRootObject

#get_root_object_id, included, #notify_root_of_child_started, #notify_root_of_finished, #set_root_object

Class Method Details

.exists_for_configurations?(configurations) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/active_worker/event.rb', line 26

def self.exists_for_configurations?(configurations)
  where(:configuration_id.in => configurations.map(&:id)).count == configurations.size
end

Instance Method Details

#event_typeObject



38
39
40
# File 'lib/active_worker/event.rb', line 38

def event_type
  self.class.name.split('::').last.underscore
end

#fields_for_viewObject



30
31
32
33
34
35
36
# File 'lib/active_worker/event.rb', line 30

def fields_for_view
  view_fields = {}
  fields.keys.each do |field|
    view_fields[field] = self.send(field)
  end
  view_fields
end

#generate_messageObject



63
64
65
# File 'lib/active_worker/event.rb', line 63

def generate_message
  "#{configuration.event_name} base message"
end

#get_pidObject



48
49
50
# File 'lib/active_worker/event.rb', line 48

def get_pid
  Process.pid.to_i
end

#get_worker_pidObject



52
53
54
55
56
# File 'lib/active_worker/event.rb', line 52

def get_worker_pid
  worker = JobQueue::QueueManager.new.active_jobs_for_configurations([configuration.to_param]).first
  return worker["pid"] if worker
  nil
end

#set_messageObject



58
59
60
61
# File 'lib/active_worker/event.rb', line 58

def set_message
  return if message
  self.message = generate_message
end

#set_process_informationObject



42
43
44
45
46
# File 'lib/active_worker/event.rb', line 42

def set_process_information
  self.host = HostInformation.hostname
  self.process_id = get_pid
  #self.worker_pid = get_worker_pid
end