Class: Flo::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/flo/task.rb

Overview

Definition of a task performed by a Command.

Instance Method Summary collapse

Constructor Details

#initialize(provider, method_sym, provider_options = {}) ⇒ Task

Creates a new Task instance

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
# File 'lib/flo/task.rb', line 20

def initialize(provider, method_sym, provider_options={})
  @provider = provider
  @method_sym = method_sym

  raise ArgumentError.new("Expected provider_options to be a Hash") unless provider_options.is_a? Hash
  @provider_options = provider_options
end

Instance Method Details

#call(args = []) ⇒ #success?

Call invokes the task on the provider instance. Additional parameters can be passed in that are merged into the parameters that were provided in #initialize. Proc values will be evaluated before being passed to the provider.

Raises:

  • (ArgumentError)


34
35
36
37
# File 'lib/flo/task.rb', line 34

def call(args=[])
  raise ArgumentError.new("Expected Array") unless args.is_a? Array
  @provider.public_send(method_sym, *merged_evaluated_args(args.dup))
end