Class: Tasking::Task
- Inherits:
-
Object
- Object
- Tasking::Task
- Defined in:
- lib/tasking/task.rb
Instance Attribute Summary collapse
-
#after_filters ⇒ Object
readonly
Returns the value of attribute after_filters.
-
#before_filters ⇒ Object
readonly
Returns the value of attribute before_filters.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parent_namespace ⇒ Object
readonly
Returns the value of attribute parent_namespace.
Instance Method Summary collapse
- #add_after_filters(*filters) ⇒ Object
- #add_before_filters(*filters) ⇒ Object
- #execute(options = {}) ⇒ Object
-
#initialize(name, parent_namespace, options = {}, &block) ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(name, parent_namespace, options = {}, &block) ⇒ Task
Returns a new instance of Task.
6 7 8 9 10 11 12 13 |
# File 'lib/tasking/task.rb', line 6 def initialize( name, parent_namespace, = {}, &block ) @name = name @parent_namespace = parent_namespace @options = Options.build( ) @block = block @before_filters = [] @after_filters = [] end |
Instance Attribute Details
#after_filters ⇒ Object (readonly)
Returns the value of attribute after_filters.
3 4 5 |
# File 'lib/tasking/task.rb', line 3 def after_filters @after_filters end |
#before_filters ⇒ Object (readonly)
Returns the value of attribute before_filters.
3 4 5 |
# File 'lib/tasking/task.rb', line 3 def before_filters @before_filters end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/tasking/task.rb', line 3 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/tasking/task.rb', line 3 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/tasking/task.rb', line 3 def @options end |
#parent_namespace ⇒ Object (readonly)
Returns the value of attribute parent_namespace.
3 4 5 |
# File 'lib/tasking/task.rb', line 3 def parent_namespace @parent_namespace end |
Instance Method Details
#add_after_filters(*filters) ⇒ Object
19 20 21 |
# File 'lib/tasking/task.rb', line 19 def add_after_filters( *filters ) @after_filters.concat( filters.flatten ) end |
#add_before_filters(*filters) ⇒ Object
15 16 17 |
# File 'lib/tasking/task.rb', line 15 def add_before_filters( *filters ) @before_filters.concat( filters.flatten ) end |
#execute(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/tasking/task.rb', line 23 def execute( = {} ) = Options.build(parent_namespace..dup) .merge!( @options ) .merge!( ) execute_task_chain( before_filters, , "Unknown before task '%s' for task '#{@name}'" ) block&.call( ) execute_task_chain( after_filters, , "Unknown after task '%s' for task '#{@name}'" ) end |