module Jujube::Macros

Macros for defining methods that make it easier to specify the parts a job.

Public Instance Methods

attribute(attribute_name) click to toggle source

A macro that defines an attribute of a job. It generates a reader and a writer for the attribute.

@param attribute_name [Symbol] The name of the attribute.

# File lib/jujube/macros.rb, line 12
def attribute(attribute_name)
  canonical_name = canonicalize(attribute_name)

  define_method attribute_name do
    config[canonical_name]
  end

  define_method "#{attribute_name}=".to_sym do |value|
    config[canonical_name] = value
  end
end
section(section_name) click to toggle source

A macro that defines a section of a job. It generates a method that returns the `Array` of components in that section.

@param section_name [Symbol] The name of the section.

# File lib/jujube/macros.rb, line 29
def section(section_name)
  define_method section_name do
    config[section_name.to_s] ||= []
  end
end