Class: Para::ComponentsConfiguration

Inherits:
Object
  • Object
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
# File 'lib/para/components_configuration.rb', line 21

def method_missing(method, *args, &block)
  component_for(method) || super
end

Instance Method Details

#component_for(identifier) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/para/components_configuration.rb', line 33

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



25
26
27
28
29
30
31
# File 'lib/para/components_configuration.rb', line 25

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

#sectionsObject



17
18
19
# File 'lib/para/components_configuration.rb', line 17

def sections
  @sections ||= []
end