Class: Tasker::ConfiguredTask

Inherits:
TaskBuilder show all
Includes:
TaskHandler
Defined in:
lib/tasker/task_builder.rb

Overview

A task handler that loads configuration from YAML

ConfiguredTask provides a base class for task handlers that load their configuration from YAML files.

Instance Attribute Summary

Attributes inherited from TaskBuilder

#config, #handler_class

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TaskHandler

included

Methods inherited from TaskBuilder

#build, from_yaml, #validate_config

Constructor Details

#initializeConfiguredTask

Create a new ConfiguredTask



428
429
430
# File 'lib/tasker/task_builder.rb', line 428

def initialize
  super(config: self.class.config)
end

Class Method Details

.configHash

Load the configuration from the YAML file

Returns:

  • (Hash)

    The loaded configuration



420
421
422
# File 'lib/tasker/task_builder.rb', line 420

def config
  @config ||= YAML.load_file(yaml_path)
end

.task_nameString

Get the task name derived from the class name

Returns:

  • (String)

    The task name



406
407
408
# File 'lib/tasker/task_builder.rb', line 406

def task_name
  @task_name ||= to_s.underscore
end

.yaml_pathString

Get the path to the YAML configuration file

Returns:

  • (String)

    The path to the YAML file



413
414
415
# File 'lib/tasker/task_builder.rb', line 413

def yaml_path
  @yaml_path ||= Rails.root.join("config/#{Tasker::Configuration.configuration.engine.task_config_directory}/#{task_name}.yaml")
end