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, param, params_spec, set, undef_param

Constructor Details

#initialize(task) ⇒ Play

Returns a new instance of Play.



46
47
48
# File 'lib/abid/play.rb', line 46

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.



44
45
46
# File 'lib/abid/play.rb', line 44

def task
  @task
end

Class Method Details

.after(&block) ⇒ Object



32
33
34
# File 'lib/abid/play.rb', line 32

def after(&block)
  hooks[:after] << block
end

.before(&block) ⇒ Object



28
29
30
# File 'lib/abid/play.rb', line 28

def before(&block)
  hooks[:before] << block
end

.helpers(*extensions, &block) ⇒ Object



19
20
21
22
# File 'lib/abid/play.rb', line 19

def helpers(*extensions, &block)
  class_eval(&block) if block_given?
  include(*extensions) if extensions.any?
end

.hooksObject



15
16
17
# File 'lib/abid/play.rb', line 15

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



36
37
38
# File 'lib/abid/play.rb', line 36

def method_added(name)
  params_spec.delete(name) # undef param
end

.setup(&block) ⇒ Object



24
25
26
# File 'lib/abid/play.rb', line 24

def setup(&block)
  hooks[:setup] << block
end

Instance Method Details

#needs(task_name, **params) ⇒ Object



54
55
56
# File 'lib/abid/play.rb', line 54

def needs(task_name, **params)
  task.enhance([[task_name, params]])
end

#preview?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/abid/play.rb', line 62

def preview?
  task.application.options.preview
end

#runObject



50
51
52
# File 'lib/abid/play.rb', line 50

def run
  # noop
end

#volatile?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/abid/play.rb', line 58

def volatile?
  volatile
end