Class: Caterer::Config::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/caterer/config/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

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

Yields:

  • ()


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_commandObject

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_dirObject

Returns the value of attribute dest_dir.



6
7
8
# File 'lib/caterer/config/base.rb', line 6

def dest_dir
  @dest_dir
end

#groupsObject (readonly)

Returns the value of attribute groups.



5
6
7
# File 'lib/caterer/config/base.rb', line 5

def groups
  @groups
end

#imagesObject (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

Yields:

  • ()


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

Yields:

  • ()


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