lib/henry/container.rb in henry-container-0.0.53 vs lib/henry/container.rb in henry-container-0.0.54

- old
+ new

@@ -21,11 +21,11 @@ # Executes the loaded tasks and stores their results. def execute self.before_execution self.tasks.select {|task| task.enabled?}.each do |task| - task.configure(self.task_params(task.name)) + task.configure(self.task_params(task.name), self.task_extended_context(task.name)) task.before_execute task.execute task.after_execute self.tasks_results << task.report end @@ -118,9 +118,34 @@ # # @param [String] task_name the target Task name. # @return [Hash] the Task custom params. def task_params(task_name) self.default_params.merge(self.params[task_name] || {}) + end + + # Return the default extended execution. + # @note Custom extended_executions will overwrite the defaults. + # + # @return [Hash] the Task default extended context + def default_extended_context + self.default_params['extended_context'] || {} + end + + # Retrun the custom extended_context fo the given task. + # @note default_extended_context will be used for undefined keys. + # + # @return [Hash] the Task custom extended context. + def extended_context + (self.params[task_name] || {})['extended_context'] + end + + # Returns the custom execution_context for the given task. + # @note default_execution_context will be used for undefined keys. + # + # @param [String] task_name the target Task name. + # @return [Hash] the Task custom execution_context. + def task_extended_context + self.default_extended_context.merge(self.extended_context[task_name] || {}) end # Returns de task hints (tasks to be executed) or an empty array if they are not defined. #