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
26
27
28
29
30
31
32
|
# File 'lib/para/components_configuration.rb', line 26
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_configuration_for(identifier) ⇒ Object
50
51
52
|
# File 'lib/para/components_configuration.rb', line 50
def component_configuration_for(identifier)
sections.map(&:components).flatten.find { |c| c.identifier.to_s == identifier.to_s }
end
|
#component_for(identifier) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/para/components_configuration.rb', line 42
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
12
13
14
15
16
|
# File 'lib/para/components_configuration.rb', line 6
def draw(&block)
return unless components_installed?
Para::LogConfig.with_log_level(:fatal) do
log_level = Rails.logger.level
Rails.logger.level = :fatal
eager_load_components!
instance_eval(&block)
build
end
end
|
#section(*args, &block) ⇒ Object
18
19
20
|
# File 'lib/para/components_configuration.rb', line 18
def section(*args, &block)
sections << Section.new(*args, &block)
end
|
#section_for(identifier) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/para/components_configuration.rb', line 34
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
22
23
24
|
# File 'lib/para/components_configuration.rb', line 22
def sections
@sections ||= []
end
|