Class: Awsm::Configulator

Inherits:
Object
  • Object
show all
Defined in:
lib/awsm/configure.rb

Instance Method Summary collapse

Constructor Details

#initializeConfigulator

Returns a new instance of Configulator.



22
23
24
25
26
# File 'lib/awsm/configure.rb', line 22

def initialize
  @spin_blocks = {}
  @dns_block = nil
  @table = {}
end

Instance Method Details

#dns(&block) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/awsm/configure.rb', line 40

def dns( &block )
  if block_given?
    @dns_block = block
    return
  end

  c = Domainatrix.new
  @dns_block.call( c )
  return c
end

#spin(preset = nil, &block) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/awsm/configure.rb', line 51

def spin( preset=nil, &block )
  if block_given?
    if preset.nil?
      preset = 'default'
    end

    @spin_blocks[ preset ] = block
    return
  end

  if preset.nil? || preset == 'default'
    preset = 'default'
    c = Spinulator.new
  else
    c = Spinulator.new( spin('default') )
  end

  if @spin_blocks[ preset ].nil?
    raise StandardError, "Invalid preset: #{preset}"
  end

  @spin_blocks[ preset ].call( c )

  return c

end

#table(table) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/awsm/configure.rb', line 28

def table( table )
  if block_given?
    @table[ table ] = Tablulatrix.new
    yield @table[ table ]
  else
    if @table[ table ].nil?
      raise StandardError, "Invalid table configuration: #{table}"
    end
    @table[ table ]
  end
end