Module: ConfigX

Defined in:
lib/config_x.rb,
lib/config_x/version.rb,
lib/config_x/interface/base.rb,
lib/config_x/interface/builder.rb,
lib/config_x/namespace_delegator.rb

Defined Under Namespace

Modules: Interface Classes: NamespaceDelegator

Constant Summary collapse

CONFIG_NAMESPACE =
'config'
VERSION =
'0.1.1'

Instance Method Summary collapse

Instance Method Details

#configurable(type, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/config_x.rb', line 9

def configurable(type, &block)
  store_maps = {}
  config_interface = Module.new
  owner_interface = Module.new

  store_maps[type] = Interface::Builder.new(config_interface, owner_interface).build(&block)

  interfaces = [
    Interface::Base,
    config_interface,
    owner_interface
  ]

  inclusion_method = case type
  when :instance
    :include
  when :class
    :extend
  else
    raise StandardError, "Type #{type} not supported in configurable. Only :instance and :class"
  end

  interfaces.each { |interface| send inclusion_method, interface }
  instance_variable_set(:@store_maps, store_maps)
end