Module: ActiveWorker::Behavior::HasRootObject

Included in:
Configuration, Event
Defined in:
lib/active_worker/behavior/has_root_object.rb

Defined Under Namespace

Modules: ClassExtensions

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



11
12
13
14
15
# File 'lib/active_worker/behavior/has_root_object.rb', line 11

def self.included(base)
  base.extend(ClassExtensions)
  base.before_save :set_root_object
  base.index({:root_object_id => -1}, {:background => true})
end

Instance Method Details

#get_root_object_idObject



35
36
37
38
39
# File 'lib/active_worker/behavior/has_root_object.rb', line 35

def get_root_object_id
  return root_object_id if root_object_id
  set_root_object
  root_object_id
end

#notify_root_of_child_startedObject



21
22
23
24
25
26
# File 'lib/active_worker/behavior/has_root_object.rb', line 21

def notify_root_of_child_started
  if root_object
    root_object.child_started
    root_object.save!
  end
end

#notify_root_of_finishedObject



28
29
30
31
32
33
# File 'lib/active_worker/behavior/has_root_object.rb', line 28

def notify_root_of_finished
  if root_object
    root_object.child_finished
    root_object.save!
  end
end

#root_ownerObject



17
18
19
# File 'lib/active_worker/behavior/has_root_object.rb', line 17

def root_owner
  nil
end

#set_root_objectObject



41
42
43
44
45
46
# File 'lib/active_worker/behavior/has_root_object.rb', line 41

def set_root_object
  return unless root_owner
  self.root_object_id = root_owner.get_root_object_id
  self.root_object_type = root_owner.root_object_type
  true
end