Class: Confuse::Namespace

Inherits:
Object
  • Object
show all
Defined in:
lib/confuse/namespace.rb

Overview

A Namespace is a container to keep configuration data seperate from the rest of the config.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Namespace

Returns a new instance of Namespace.



9
10
11
12
# File 'lib/confuse/namespace.rb', line 9

def initialize(&block)
  @items = {}
  block.call(self) if block_given?
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



7
8
9
# File 'lib/confuse/namespace.rb', line 7

def items
  @items
end

Instance Method Details

#[](key) ⇒ Object



18
19
20
# File 'lib/confuse/namespace.rb', line 18

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

#add_item(name, opts = {}) ⇒ Object



14
15
16
# File 'lib/confuse/namespace.rb', line 14

def add_item(name, opts = {})
  @items[name] = Item.new(name, opts)
end