lib/howzit/task.rb in howzit-2.0.15 vs lib/howzit/task.rb in howzit-2.0.16

- old
+ new

@@ -6,15 +6,25 @@ attr_reader :type, :title, :action, :parent, :optional, :default ## ## Initialize a Task object ## - def initialize(params, optional: false, default: true) - @type = params[:type] - @title = params[:title] - @action = params[:action].render_arguments - @parent = params[:parent] || nil + ## @param attributes [Hash] the task attributes + ## @param optional [Boolean] Task requires + ## confirmation + ## @param default [Boolean] Default response + ## for confirmation dialog + ## + ## @option attributes :type [Symbol] task type (:block, :run, :include, :copy) + ## @option attributes :title [String] task title + ## @option attributes :action [String] task action + ## @option attributes :parent [String] title of nested (included) topic origin + def initialize(attributes, optional: false, default: true) + @type = attributes[:type] || :run + @title = attributes[:title] || nil + @action = attributes[:action].render_arguments || nil + @parent = attributes[:parent] || nil @optional = optional @default = default end ## @@ -54,10 +64,10 @@ end ## ## Execute an include task ## - ## @return [Integer] number of tasks executed + ## @return [Array] [[Array] output, [Integer] number of tasks executed] ## def run_include output = [] matches = Howzit.buildnote.find_topic(@action) raise "Topic not found: #{@action}" if matches.empty?