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

Parameters:

  • provider (Provider)

    The provider to send the message to

  • The (Symbol)

    method you wish to call on the provider

  • provider_options={} (Hash)

    A hash of options to be passed when invoking the method on the provider. Any lambda values will be called during the execution stage when #call is invoked

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.

Parameters:

  • args={} (Hash)

    Additional arguments to pass to the provider method

Returns:

  • (#success?)

    Response of the provider’s method



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

def call(args={})
  @provider.public_send(method_sym, merged_evaluated_args(args))
end