Class: Grenache::Configuration

Inherits:
BaseConfiguration show all
Defined in:
lib/grenache/configurable.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseConfiguration

#method_missing, #values

Constructor Details

#initialize(params = {}) ⇒ Configuration

Returns a new instance of Configuration.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/grenache/configurable.rb', line 18

def initialize(params = {})
  @values = self.class.default.values.clone

  params.each do |k, v|
    @values[k.to_s] = v
  end

  # sanitize urls
  if not @values["grape_address"].end_with?("/")
    @values["grape_address"] = @values["grape_address"] + "/"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Grenache::BaseConfiguration

Class Method Details

.defaultObject



35
36
37
# File 'lib/grenache/configurable.rb', line 35

def self.default
  @defaults ||= BaseConfiguration.new
end

.set_default {|default| ... } ⇒ Object

Yields:



31
32
33
# File 'lib/grenache/configurable.rb', line 31

def self.set_default &block
  yield default
end