Class: Para::ComponentsConfiguration
- Inherits:
-
Object
- Object
- Para::ComponentsConfiguration
show all
- Defined in:
- lib/para/components_configuration.rb
Defined Under Namespace
Classes: Component, Section, UndefinedComponentTypeError
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/para/components_configuration.rb', line 21
def method_missing(method, *args, &block)
if (component = component_for(method))
component.tap(&ActiveDecorator::Decorator.instance.method(:decorate))
else
super
end
end
|
Instance Method Details
#component_for(identifier) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/para/components_configuration.rb', line 37
def component_for(identifier)
if (component = components_cache[identifier])
component
elsif (component_id = components_ids_hash[identifier])
components_cache[identifier] = Para::Component::Base.find(component_id)
end
end
|
#draw(&block) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/para/components_configuration.rb', line 6
def draw(&block)
return unless components_installed?
eager_load_components!
instance_eval(&block)
build
end
|
#section(*args, &block) ⇒ Object
13
14
15
|
# File 'lib/para/components_configuration.rb', line 13
def section(*args, &block)
sections << Section.new(*args, &block)
end
|
#section_for(identifier) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/para/components_configuration.rb', line 29
def section_for(identifier)
if (section = sections_cache[identifier])
section
elsif (section_id = sections_ids_hash[identifier])
sections_cache[identifier] = Para::ComponentSection.find(section_id)
end
end
|
#sections ⇒ Object
17
18
19
|
# File 'lib/para/components_configuration.rb', line 17
def sections
@sections ||= []
end
|