Module: Topping::Configurable::HQ

Defined in:
lib/topping/configurable/hq.rb

Overview

Since:

  • 0.0.1

Defined Under Namespace

Modules: ChildClassMethods

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.hq_classConfiguration

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The top-level Configurable Class

Returns:

Since:

  • 0.0.1



56
57
58
# File 'lib/topping/configurable/hq.rb', line 56

def hq_class
  @hq_class
end

Instance Attribute Details

#name_spaceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The top-level Topping::ConfigurationBuilder attribute.

Since:

  • 0.0.1



12
13
14
# File 'lib/topping/configurable/hq.rb', line 12

def name_space
  @name_space
end

#rootConfiguration

The top-level Topping::ConfigurationBuilder attribute.

Returns:

Since:

  • 0.0.1



8
9
10
# File 'lib/topping/configurable/hq.rb', line 8

def root
  @root
end

Class Method Details

.extended(klass) ⇒ Object

Since:

  • 0.0.1



62
63
64
65
66
67
68
69
# 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) ⇒ Object

Since:

  • 0.0.1



58
59
60
# File 'lib/topping/configurable/hq.rb', line 58

def mapping(klass)
  hq_class.mapping(klass)
end

Instance Method Details

#buildvoid

This method returns an undefined value.

Sets a configuration attribute on the application.

Since:

  • 0.0.1



30
31
32
# File 'lib/topping/configurable/hq.rb', line 30

def build
  root.build
end

#config(*args, **kwargs, &block) ⇒ void

This method returns an undefined value.

Sets a configuration attribute on the application.

See Also:

Since:

  • 0.0.1



18
19
20
21
22
23
24
25
# 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) ⇒ Object

Since:

  • 0.0.1



47
48
49
50
# File 'lib/topping/configurable/hq.rb', line 47

def inherited(klass)
  klass.extend(Topping::Configurable::HQ::ChildClassMethods)
  klass.root = root
end

#mapping(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.0.1



35
36
37
38
39
40
41
42
43
44
45
# 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