Class: Stormtroopers::Trooper
- Inherits:
-
Object
- Object
- Stormtroopers::Trooper
show all
- Defined in:
- lib/stormtroopers/trooper.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(parameters = {}, &block) ⇒ Trooper
Returns a new instance of Trooper.
5
6
7
8
|
# File 'lib/stormtroopers/trooper.rb', line 5
def initialize(parameters = {}, &block)
@parameters = parameters
@task = block
end
|
Instance Attribute Details
#parameters ⇒ Object
Returns the value of attribute parameters.
3
4
5
|
# File 'lib/stormtroopers/trooper.rb', line 3
def parameters
@parameters
end
|
#task ⇒ Object
Returns the value of attribute task.
3
4
5
|
# File 'lib/stormtroopers/trooper.rb', line 3
def task
@task
end
|
Instance Method Details
#after_run ⇒ Object
14
15
16
|
# File 'lib/stormtroopers/trooper.rb', line 14
def after_run
end
|
#before_run ⇒ Object
10
11
12
|
# File 'lib/stormtroopers/trooper.rb', line 10
def before_run
end
|
#exception(exception) ⇒ Object
18
19
20
21
|
# File 'lib/stormtroopers/trooper.rb', line 18
def exception(exception)
raise exception
end
|
#logger ⇒ Object
31
32
33
|
# File 'lib/stormtroopers/trooper.rb', line 31
def logger
Manager.logger
end
|
#run ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/stormtroopers/trooper.rb', line 23
def run
before_run
task.call
after_run
rescue => e
exception(e)
end
|