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



27
28
29
# File 'lib/falcon/configuration.rb', line 27

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

Instance Attribute Details

#environmentsObject (readonly)

Returns the value of attribute environments.



31
32
33
# File 'lib/falcon/configuration.rb', line 31

def environments
  @environments
end

Instance Method Details

#add(environment) ⇒ Object

Raises:

  • (KeyError)


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

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



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

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



59
60
61
# File 'lib/falcon/configuration.rb', line 59

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