Module: Jujube::Macros
- Includes:
- Utils
- Included in:
- Components::Axes, Components::Scm, Job
- Defined in:
- lib/jujube/macros.rb
Overview
Macros for defining methods that make it easier to specify the parts a job.
Instance Method Summary collapse
-
#attribute(attribute_name) ⇒ Object
A macro that defines an attribute of a job.
-
#section(section_name) ⇒ Object
A macro that defines a section of a job.
Instance Method Details
#attribute(attribute_name) ⇒ Object
A macro that defines an attribute of a job. It generates a reader and a writer for the attribute.
12 13 14 15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
A macro that defines a section of a job.
It generates a method that returns the Array
of components
in that section.
29 30 31 32 33 |
# File 'lib/jujube/macros.rb', line 29 def section(section_name) define_method section_name do config[section_name.to_s] ||= [] end end |