Module: ActiveWorker::Expandable

Defined in:
lib/active_worker/expandable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/active_worker/expandable.rb', line 4

def self.included(base)
  base.template_field :number_of_threads, type: Integer, default: 1
  base.template_field :number_of_workers, type: Integer, default: 1
  base.belongs_to :thread_root_configuration, :polymorphic => true
  base.has_many :thread_expanded_configurations,
                :as => :thread_root_configuration,
                :class_name => 'ActiveWorker::Configuration',
                :autosave => true
end

Instance Method Details

#configurations_for_eventsObject



28
29
30
# File 'lib/active_worker/expandable.rb', line 28

def configurations_for_events
  [self] + thread_expanded_configurations
end

#expand_for_threadsObject



14
15
16
17
18
19
20
21
# File 'lib/active_worker/expandable.rb', line 14

def expand_for_threads
  maps = expansion_maps_for_threads
  maps[1..-1].each do |map_hash|
    map_hash[:thread_root_configuration_id] = id
    map_hash[:thread_root_configuration_type] = _type
  end
  expand_from_maps(maps)
end

#expand_for_workersObject



23
24
25
26
# File 'lib/active_worker/expandable.rb', line 23

def expand_for_workers
  maps = expansion_maps_for_workers
  expand_from_maps(maps)
end