Class: ConfigPlus::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/config_plus/config.rb

Overview

Configuration of ConfigPlus

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



16
17
18
19
20
21
22
# File 'lib/config_plus/config.rb', line 16

def initialize
  props = self.class.default_properties.each do |k, v|
    instance_variable_set("@#{k}", v)
  end

  setup_attrs(props.keys)
end

Class Method Details

.default_propertiesObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/config_plus/config.rb', line 4

def self.default_properties
  {
    config_method: :config,
    extension: nil,
    namespace: nil,
    node_model: Node,
    root_dir: nil,
    source: nil,
    loader_logic: :default,
  }
end

Instance Method Details

#has_property?(name) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/config_plus/config.rb', line 44

def has_property?(name)
  instance_variable_defined?("@#{name}")
end

#loaderObject

returns a new loader instance



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

def loader
  Loader.new(self)
end

#loader_logicObject

returns loader class specified by loader_logic property



30
31
32
33
34
35
36
37
38
# File 'lib/config_plus/config.rb', line 30

def loader_logic
  return @loader_logic if @loader_logic.is_a?(Class)

  name = ::ConfigPlus::Helper.classify(@loader_logic.to_s)
  name = "#{name}LoaderLogic"
  raise "Unknown loader logic named `#{name}'" unless
    ::ConfigPlus::const_defined?(name)
  ::ConfigPlus::const_get(name)
end

#property_set(name, value) ⇒ Object



48
49
50
# File 'lib/config_plus/config.rb', line 48

def property_set(name, value)
  instance_variable_set("@#{name}", value)
end

#versionObject



40
41
42
# File 'lib/config_plus/config.rb', line 40

def version
  VERSION
end