Class: Rivet::BaseConfig

Inherits:
OpenState show all
Defined in:
lib/rivet/common/base_config.rb

Direct Known Subclasses

AutoscaleConfig, Ec2Config

Instance Attribute Summary collapse

Attributes inherited from OpenState

#generated_attributes, #required_fields

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OpenState

#install_get_or_set, #method_missing, #validate

Constructor Details

#initialize(name, load_path = '.', &block) ⇒ BaseConfig

Returns a new instance of BaseConfig.



14
15
16
17
18
19
20
# File 'lib/rivet/common/base_config.rb', line 14

def initialize(name, load_path='.', &block)
  super()
  @name = name
  @path = load_path
  @bootstrap = OpenState.new
  instance_eval(&block) if block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rivet::OpenState

Instance Attribute Details

#bootstrapObject

Returns the value of attribute bootstrap.



6
7
8
# File 'lib/rivet/common/base_config.rb', line 6

def bootstrap
  @bootstrap
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/rivet/common/base_config.rb', line 5

def name
  @name
end

Class Method Details

.from_file(dsl_file, load_path = '.') ⇒ Object



8
9
10
11
12
# File 'lib/rivet/common/base_config.rb', line 8

def self.from_file(dsl_file, load_path='.')
  name = File.basename(dsl_file, '.rb')
  data = Proc.new { eval(File.read(dsl_file)) }
  new(name, load_path, &data)
end

Instance Method Details

#normalize_security_groupsObject



35
36
37
# File 'lib/rivet/common/base_config.rb', line 35

def normalize_security_groups
  security_groups.sort
end

#path(*args) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rivet/common/base_config.rb', line 22

def path(*args)
  if args.size < 1
    @path
  else
    File.join(@path, *args)
  end
end

#post(&block) ⇒ Object



30
31
32
33
# File 'lib/rivet/common/base_config.rb', line 30

def post(&block)
  return @block if block.nil?
  @block = block
end