Class: Minionizer::TaskTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/core/task_template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, options = {}) ⇒ TaskTemplate

Returns a new instance of TaskTemplate.



5
6
7
8
# File 'lib/core/task_template.rb', line 5

def initialize(session, options = {})
  @session = session
  @options = options.with_indifferent_access
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/core/task_template.rb', line 10

def method_missing(method_name, *arguments, &block)
  if options.key?(method_name)
    options[method_name]
  else
    super
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/core/task_template.rb', line 3

def options
  @options
end

#sessionObject (readonly)

Returns the value of attribute session.



3
4
5
# File 'lib/core/task_template.rb', line 3

def session
  @session
end

Instance Method Details

#download_file(source, destination) ⇒ Object



22
23
24
# File 'lib/core/task_template.rb', line 22

def download_file(source, destination)
  session.exec(%Q{bash -c "mkdir -p #{destination}; cd #{destination}; wget -nc #{source}"})
end

#respond_to?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/core/task_template.rb', line 18

def respond_to?(method_name, include_private = false)
  options.key?(method_name) || super
end