Class: Planter::Config

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

Overview

Configuration class

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Hash

#deep_freeze, #deep_merge, #deep_thaw, #stringify, #stringify!, #stringify_keys, #stringify_keys!, #symbolize_keys, #symbolize_keys!

Constructor Details

#initializeConfig

Initialize a new Config object for a template



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/planter/config.rb', line 11

def initialize
  super()

  @config = initial_config
  @template = Planter.template

  load_template

  die('No configuration found', :config) unless @config

  generate_accessors
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template.



6
7
8
# File 'lib/planter/config.rb', line 6

def template
  @template
end

Instance Method Details

#[](key) ⇒ String

Get a config key

Parameters:

Returns:



35
36
37
# File 'lib/planter/config.rb', line 35

def [](key)
  @config[key]
end

#[]=(key, value) ⇒ Object

Set a config option

Parameters:



45
46
47
48
# File 'lib/planter/config.rb', line 45

def []=(key, value)
  @config[key.to_sym] = value
  generate_accessors
end

#to_sObject

String representation of the configuration



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

def to_s
  @config.to_s
end