Class: Toaster::TaskExecution
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Toaster::TaskExecution
- Defined in:
- lib/toaster/model/task_execution.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#get_used_parameters ⇒ Object
Return a map => value of parameter values that were used for this task execution.
-
#initialize(attr_hash) ⇒ TaskExecution
constructor
A new instance of TaskExecution.
- #reduce_and_set_state_after(state) ⇒ Object
- #relevant_state_changes ⇒ Object
Constructor Details
#initialize(attr_hash) ⇒ TaskExecution
Returns a new instance of TaskExecution.
22 23 24 25 26 27 28 29 30 |
# File 'lib/toaster/model/task_execution.rb', line 22 def initialize(attr_hash) if !attr_hash[:uuid] attr_hash[:uuid] = Util.generate_short_uid() end if !attr_hash[:start_time] attr_hash[:start_time] = TimeStamp.now.to_i end super(attr_hash) end |
Class Method Details
.find(criteria = {}) ⇒ Object
66 67 68 |
# File 'lib/toaster/model/task_execution.rb', line 66 def self.find(criteria={}) DB.find_activerecord(TaskExecution, criteria) end |
.load_all_for_automation(auto) ⇒ Object
70 71 72 73 |
# File 'lib/toaster/model/task_execution.rb', line 70 def self.load_all_for_automation(auto) return joins(:automation_run).where( :automation_runs => {:automation_id => auto.id}) end |
Instance Method Details
#get_used_parameters ⇒ Object
Return a map => value of parameter values that were used for this task execution.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/toaster/model/task_execution.rb', line 36 def get_used_parameters() result = {} run_attributes = automation_run.get_flat_attributes() task.task_parameters.each do |p| if p value = run_attributes[p.key] result[p.key] = value end end return result end |
#reduce_and_set_state_after(state) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/toaster/model/task_execution.rb', line 56 def reduce_and_set_state_after(state) self.state_after = state # limit the number of state properties which are # saved for the pre-state and the post-state. states_new = SystemState.reduce_state_size(state_before, state_after) #puts "states before/after #{self}: #{state_after} #{states_new[1]}" self.state_before = states_new[0] self.state_after = states_new[1] end |
#relevant_state_changes ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/toaster/model/task_execution.rb', line 48 def relevant_state_changes() result = state_changes.to_a.dup ignore_props = SystemState.read_ignore_properties() # remove ignored properties from state changes SystemState.remove_ignore_props!(result, ignore_props) return result end |