Class: Take::Project::Actionable

Inherits:
Object
  • Object
show all
Defined in:
lib/take/project/actionable.rb

Overview

Handles actions that might be taken from within a build action; used in Converts and Targets.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&blk) ⇒ Actionable

Returns a new instance of Actionable.



10
11
12
13
# File 'lib/take/project/actionable.rb', line 10

def initialize(&blk)
  @data = {}
  @block = blk
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/take/project/actionable.rb', line 27

def method_missing(method, *args, &block)
  if @data.key?(method) && args.size == 0 && !block_given?
    @data[method]
  else
    super
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/take/project/actionable.rb', line 8

def data
  @data
end

Instance Method Details

#call(project, data = {}) ⇒ Object



20
21
22
23
24
25
# File 'lib/take/project/actionable.rb', line 20

def call(project, data = {})
  @data = data.merge(
    :curdir => project.path,
    :env    => project.env)
  instance_exec(@block)
end

#respond_to_missing?(method, _) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/take/project/actionable.rb', line 35

def respond_to_missing?(method, _)
  @data.key?(method)
end

#run(command, arguments) ⇒ Object



15
16
17
18
# File 'lib/take/project/actionable.rb', line 15

def run(command, arguments)
  runner = Command::Runner.new(command, arguments)
  runner.pass!
end