Module: Topping::Configurable::HQ
- Defined in:
- lib/topping/configurable/hq.rb
Overview
Defined Under Namespace
Modules: ChildClassMethods
Class Attribute Summary collapse
-
.hq_class ⇒ Configuration
private
The top-level Configurable Class.
Instance Attribute Summary collapse
-
#name_space ⇒ Object
private
The top-level Topping::ConfigurationBuilder attribute.
-
#root ⇒ Configuration
The top-level Topping::ConfigurationBuilder attribute.
Class Method Summary collapse
Instance Method Summary collapse
-
#build ⇒ void
Sets a configuration attribute on the application.
-
#config(*args, **kwargs, &block) ⇒ void
Sets a configuration attribute on the application.
- #inherited(klass) ⇒ Object
- #mapping(klass) ⇒ Object private
Class Attribute Details
.hq_class ⇒ Configuration
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
56 57 58 |
# File 'lib/topping/configurable/hq.rb', line 56 def hq_class @hq_class end |
Instance Attribute Details
#name_space ⇒ 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.
The top-level Topping::ConfigurationBuilder attribute.
12 13 14 |
# File 'lib/topping/configurable/hq.rb', line 12 def name_space @name_space end |
#root ⇒ Configuration
The top-level Topping::ConfigurationBuilder attribute.
8 9 10 |
# File 'lib/topping/configurable/hq.rb', line 8 def root @root end |
Class Method Details
.extended(klass) ⇒ Object
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
58 59 60 |
# File 'lib/topping/configurable/hq.rb', line 58 def mapping(klass) hq_class.mapping(klass) end |
Instance Method Details
#build ⇒ void
This method returns an undefined value.
Sets a configuration attribute on the application.
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.
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
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.
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 |