Class: Falcon::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/falcon/configuration.rb

Defined Under Namespace

Classes: Loader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verbose = false) ⇒ Configuration

Returns a new instance of Configuration.



25
26
27
# File 'lib/falcon/configuration.rb', line 25

def initialize(verbose = false)
	@environments = {}
end

Instance Attribute Details

#environmentsObject (readonly)

Returns the value of attribute environments.



29
30
31
# File 'lib/falcon/configuration.rb', line 29

def environments
  @environments
end

Instance Method Details

#add(environment) ⇒ Object

Raises:

  • (KeyError)


43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/falcon/configuration.rb', line 43

def add(environment)
	name = environment.name
	
	unless name
		raise ArgumentError, "Environment name is nil #{environment.inspect}"
	end
	
	environment = environment.flatten
	
	raise KeyError.new("#{name.inspect} is already set", key: name) if @environments.key?(name)
	
	@environments[name] = environment
end

#each(key = :authority) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/falcon/configuration.rb', line 31

def each(key = :authority)
	return to_enum(key) unless block_given?
	
	@environments.each do |name, environment|
		environment = environment.flatten
		
		if environment.include?(key)
			yield environment
		end
	end
end

#load_file(path) ⇒ Object



57
58
59
# File 'lib/falcon/configuration.rb', line 57

def load_file(path)
	Loader.load_file(self, path)
end