Class: Modular::Configuration
- Inherits:
-
Object
- Object
- Modular::Configuration
- Includes:
- Singleton
- Defined in:
- lib/modular/configuration.rb
Instance Attribute Summary collapse
-
#layouts ⇒ Object
readonly
Returns the value of attribute layouts.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#layouts ⇒ Object (readonly)
Returns the value of attribute layouts.
7 8 9 |
# File 'lib/modular/configuration.rb', line 7 def layouts @layouts end |
Class Method Details
.config ⇒ Object
9 10 11 |
# File 'lib/modular/configuration.rb', line 9 def self.config self.instance end |
.configure(&block) ⇒ Object
13 14 15 16 17 |
# File 'lib/modular/configuration.rb', line 13 def self.configure(&block) instance = self.instance instance.instance_eval &block if block_given? instance end |
Instance Method Details
#layout(id) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/modular/configuration.rb', line 19 def layout(id) if layouts.has_key?(id) layouts[id] else raise "Layout '#{id}' not found" end end |
#register_layout(layout, mod = :container, params = {}, &block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/modular/configuration.rb', line 27 def register_layout(layout, mod = :container, params = {}, &block) @layouts ||= Hash.new.with_indifferent_access if mod.is_a? Components::Base @layouts[layout.to_s] = mod else root_layout = Modular.create mod, params root_layout.instance_eval &block if block_given? @layouts[layout.to_s] = root_layout end end |