Class: Chamber

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/chamber/file.rb,
lib/chamber.rb,
lib/chamber/version.rb,
lib/chamber/file_set.rb,
lib/chamber/settings.rb,
lib/chamber/namespace_set.rb,
lib/chamber/rails/railtie.rb,
lib/chamber/system_environment.rb

Overview

Internal: Gives access to the existing environment for importing/exporting values.

Defined Under Namespace

Modules: Rails, SystemEnvironment Classes: File, FileSet, NamespaceSet, Settings

Constant Summary collapse

VERSION =
'1.0.3'

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/chamber.rb', line 59

def method_missing(name, *args)
  if settings.respond_to?(name)
    return settings.public_send(name, *args)
  end

  super
end

Instance Attribute Details

#basepathObject

Returns the value of attribute basepath.



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

def basepath
  @basepath
end

#files=(value) ⇒ Object

Sets the attribute files

Parameters:

  • value

    the value to set the attribute files to.



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

def files=(value)
  @files = value
end

#settingsObject



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

def settings
  @settings ||= -> do
    @settings = Settings.new

    files.to_settings do |parsed_settings|
      @settings.merge! parsed_settings
    end

    @settings
  end.call
end

Instance Method Details

#filenamesObject



39
40
41
# File 'lib/chamber.rb', line 39

def filenames
  self.files.filenames
end

#load(options) ⇒ Object



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

def load(options)
  self.settings = nil
  self.basepath = options[:basepath] || ''
  file_patterns = options[:files] || [
                    self.basepath + 'credentials*.yml',
                    self.basepath + 'settings*.yml',
                    self.basepath + 'settings' ]
  self.files    = FileSet.new files:      file_patterns,
                              namespaces: options.fetch(:namespaces, {})
end

#namespacesObject



43
44
45
# File 'lib/chamber.rb', line 43

def namespaces
  settings.namespaces
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/chamber.rb', line 67

def respond_to_missing?(name, include_private = false)
  settings.respond_to?(name, include_private)
end

#to_s(*args) ⇒ Object



71
72
73
# File 'lib/chamber.rb', line 71

def to_s(*args)
  settings.to_s(*args)
end