Class: Caterer::Config::Base
- Inherits:
-
Object
- Object
- Caterer::Config::Base
- Defined in:
- lib/caterer/config/base.rb
Instance Attribute Summary collapse
-
#default_command ⇒ Object
Returns the value of attribute default_command.
-
#dest_dir ⇒ Object
Returns the value of attribute dest_dir.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
Instance Method Summary collapse
- #group(name) {|| ... } ⇒ Object
- #image(name) {|| ... } ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #member(name, &block) ⇒ Object
-
#method_missing(method, *args) {|| ... } ⇒ Object
here we allow custom config keys.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 |
# File 'lib/caterer/config/base.rb', line 8 def initialize @images = {} @groups = {} @keys = {} @dest_dir = '/opt/cater' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) {|| ... } ⇒ Object
here we allow custom config keys
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/caterer/config/base.rb', line 34 def method_missing(method, *args, &block) @keys[method] ||= begin if klass = Caterer.config_keys.get(method) klass.new else super end end yield @keys[method] if block_given? @keys[method] end |
Instance Attribute Details
#default_command ⇒ Object
Returns the value of attribute default_command.
6 7 8 |
# File 'lib/caterer/config/base.rb', line 6 def default_command @default_command end |
#dest_dir ⇒ Object
Returns the value of attribute dest_dir.
6 7 8 |
# File 'lib/caterer/config/base.rb', line 6 def dest_dir @dest_dir end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
5 6 7 |
# File 'lib/caterer/config/base.rb', line 5 def groups @groups end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
5 6 7 |
# File 'lib/caterer/config/base.rb', line 5 def images @images end |
Instance Method Details
#group(name) {|| ... } ⇒ Object
21 22 23 24 25 |
# File 'lib/caterer/config/base.rb', line 21 def group(name) @groups[name] ||= Group.new(name) yield @groups[name] if block_given? @groups[name] end |
#image(name) {|| ... } ⇒ Object
15 16 17 18 19 |
# File 'lib/caterer/config/base.rb', line 15 def image(name) @images[name] ||= Image.new(name) yield @images[name] if block_given? @images[name] end |
#member(name, &block) ⇒ Object
27 28 29 30 31 |
# File 'lib/caterer/config/base.rb', line 27 def member(name, &block) group(:default) do |d| d.member(name, &block) end end |