Class: Tasker::ConfiguredTask
- Inherits:
-
TaskBuilder
- Object
- TaskBuilder
- Tasker::ConfiguredTask
- 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
Class Method Summary collapse
-
.config ⇒ Hash
Load the configuration from the YAML file.
-
.task_name ⇒ String
Get the task name derived from the class name.
-
.yaml_path ⇒ String
Get the path to the YAML configuration file.
Instance Method Summary collapse
-
#initialize ⇒ ConfiguredTask
constructor
Create a new ConfiguredTask.
Methods included from TaskHandler
Methods inherited from TaskBuilder
#build, from_yaml, #validate_config
Constructor Details
#initialize ⇒ ConfiguredTask
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
.config ⇒ Hash
Load the configuration from the YAML file
420 421 422 |
# File 'lib/tasker/task_builder.rb', line 420 def config @config ||= YAML.load_file(yaml_path) end |
.task_name ⇒ String
Get the task name derived from the class name
406 407 408 |
# File 'lib/tasker/task_builder.rb', line 406 def task_name @task_name ||= to_s.underscore end |
.yaml_path ⇒ String
Get the path to the YAML configuration 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 |