Class: Abid::Play

Inherits:
Object
  • Object
show all
Extended by:
PlayCore
Defined in:
lib/abid/play.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PlayCore

include, set

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

.taskObject

Returns the value of attribute task.



8
9
10
# File 'lib/abid/play.rb', line 8

def task
  @task
end

Instance Attribute Details

#taskObject (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

.hooksObject



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_specObject



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

Returns:

  • (Boolean)


76
77
78
# File 'lib/abid/play.rb', line 76

def preview?
  task.application.options.preview
end

#runObject



64
65
66
# File 'lib/abid/play.rb', line 64

def run
  # noop
end

#volatile?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/abid/play.rb', line 72

def volatile?
  volatile
end