Class: Abid::Play
Class Attribute Summary collapse
-
.task ⇒ Object
Returns the value of attribute task.
Instance Attribute Summary collapse
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Class Method Summary collapse
- .after(&block) ⇒ Object
- .before(&block) ⇒ Object
- .helpers(*extensions, &block) ⇒ Object
- .hooks ⇒ Object
- .inherited(child) ⇒ Object
- .method_added(name) ⇒ Object
- .param(name, **param_spec) ⇒ Object
- .params_spec ⇒ Object
- .setup(&block) ⇒ Object
- .undef_param(name) ⇒ Object
Instance Method Summary collapse
-
#initialize(task) ⇒ Play
constructor
A new instance of Play.
- #needs(task_name, **params) ⇒ Object
- #preview? ⇒ Boolean
- #run ⇒ Object
- #volatile? ⇒ Boolean
Methods included from PlayCore
Constructor Details
#initialize(task) ⇒ Play
Returns a new instance of Play.
60 61 62 |
# File 'lib/abid/play.rb', line 60 def initialize(task) @task = task end |
Class Attribute Details
.task ⇒ Object
Returns the value of attribute task.
8 9 10 |
# File 'lib/abid/play.rb', line 8 def task @task end |
Instance Attribute Details
#task ⇒ Object (readonly)
Returns the value of attribute task.
58 59 60 |
# File 'lib/abid/play.rb', line 58 def task @task end |
Class Method Details
.after(&block) ⇒ Object
46 47 48 |
# File 'lib/abid/play.rb', line 46 def after(&block) hooks[:after] << block end |
.before(&block) ⇒ Object
42 43 44 |
# File 'lib/abid/play.rb', line 42 def before(&block) hooks[:before] << block end |
.helpers(*extensions, &block) ⇒ Object
33 34 35 36 |
# File 'lib/abid/play.rb', line 33 def helpers(*extensions, &block) class_eval(&block) if block_given? include(*extensions) if extensions.any? end |
.hooks ⇒ Object
29 30 31 |
# File 'lib/abid/play.rb', line 29 def hooks @hooks ||= Hash.new { |h, k| h[k] = [] } end |
.inherited(child) ⇒ Object
10 11 12 13 |
# File 'lib/abid/play.rb', line 10 def inherited(child) params_spec.each { |k, v| child.params_spec[k] = v.dup } hooks.each { |k, v| child.hooks[k] = v.dup } end |
.method_added(name) ⇒ Object
50 51 52 |
# File 'lib/abid/play.rb', line 50 def method_added(name) params_spec.delete(name) # undef param end |
.param(name, **param_spec) ⇒ Object
19 20 21 22 |
# File 'lib/abid/play.rb', line 19 def param(name, **param_spec) define_method(name) { task.params[name] } params_spec[name] = { significant: true }.merge(param_spec) end |
.params_spec ⇒ Object
15 16 17 |
# File 'lib/abid/play.rb', line 15 def params_spec @params_spec ||= {} end |
.setup(&block) ⇒ Object
38 39 40 |
# File 'lib/abid/play.rb', line 38 def setup(&block) hooks[:setup] << block end |
.undef_param(name) ⇒ Object
24 25 26 27 |
# File 'lib/abid/play.rb', line 24 def undef_param(name) params_spec.delete(name) undef_method(name) if method_defined?(name) end |
Instance Method Details
#needs(task_name, **params) ⇒ Object
68 69 70 |
# File 'lib/abid/play.rb', line 68 def needs(task_name, **params) task.enhance([[task_name, params]]) end |
#preview? ⇒ Boolean
76 77 78 |
# File 'lib/abid/play.rb', line 76 def preview? task.application..preview end |
#run ⇒ Object
64 65 66 |
# File 'lib/abid/play.rb', line 64 def run # noop end |
#volatile? ⇒ Boolean
72 73 74 |
# File 'lib/abid/play.rb', line 72 def volatile? volatile end |