module Topping::Configurable::HQ

Attributes

hq_class[RW]

The top-level Configurable Class @api private @return [Configuration] The root attribute.

name_space[RW]

The top-level {ConfigurationBuilder} attribute. @api private

root[RW]

The top-level {ConfigurationBuilder} attribute. @return [Configuration] The root attribute.

Public Class Methods

extended(klass) click to toggle source
Calls superclass method
# File lib/topping/configurable/hq.rb, line 62
def extended(klass)
  super
  self.hq_class = klass
  klass.name_space = Topping.underscore_namespace(klass)

  config = Topping.root.config(klass.name_space.first)
  klass.root = config
end
mapping(klass) click to toggle source
# File lib/topping/configurable/hq.rb, line 58
def mapping(klass)
  hq_class.mapping(klass)
end

Public Instance Methods

build() click to toggle source

Sets a configuration attribute on the application. @return [void] @since 0.0.1

# File lib/topping/configurable/hq.rb, line 30
def build
  root.build
end
config(*args, **kwargs, &block) click to toggle source

Sets a configuration attribute on the application. @return [void] @since 0.0.1 @see ConfigurationBuilder#config

# File lib/topping/configurable/hq.rb, line 18
def config(*args, **kwargs, &block)
  if block
    root.config(*args, **kwargs, &block)
  else
    root.config(*args, **kwargs)
  end
  build
end
inherited(klass) click to toggle source
# File lib/topping/configurable/hq.rb, line 47
def inherited(klass)
  klass.extend(Topping::Configurable::HQ::ChildClassMethods)
  klass.root = root
end
mapping(klass) click to toggle source

@api private

# File lib/topping/configurable/hq.rb, line 35
def mapping(klass)
  keys = Topping.underscore_namespace(klass) - name_space
  klass_name = keys.pop

  parent = keys.reduce(root) do |memo, key|
    config = memo.children.find { |child| child.name == key }
    config = memo.config(key) if config.nil?
    config
  end
  parent.combine(klass_name, klass.configuration_builder)
end