Class: Maglev::PageComponent

Inherits:
BaseComponent show all
Defined in:
app/components/maglev/page_component.rb

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#view_context

Instance Method Summary collapse

Methods inherited from BaseComponent

#build, #build_content, #build_settings_map, #settings_proxy

Constructor Details

#initialize(site:, theme:, page:, page_sections:, templates_root_path:, config:) ⇒ PageComponent

rubocop:disable Lint/MissingSuper, Metrics/ParameterLists



8
9
10
11
12
13
14
15
# File 'app/components/maglev/page_component.rb', line 8

def initialize(site:, theme:, page:, page_sections:, templates_root_path:, config:)
  @site = site
  @theme = theme
  @page = page
  @page_sections = page_sections
  @templates_root_path = templates_root_path
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'app/components/maglev/page_component.rb', line 5

def config
  @config
end

#pageObject (readonly)

Returns the value of attribute page.



5
6
7
# File 'app/components/maglev/page_component.rb', line 5

def page
  @page
end

#page_sectionsObject (readonly)

Returns the value of attribute page_sections.



5
6
7
# File 'app/components/maglev/page_component.rb', line 5

def page_sections
  @page_sections
end

#siteObject (readonly)

Returns the value of attribute site.



5
6
7
# File 'app/components/maglev/page_component.rb', line 5

def site
  @site
end

#templates_root_pathObject (readonly)

Returns the value of attribute templates_root_path.



5
6
7
# File 'app/components/maglev/page_component.rb', line 5

def templates_root_path
  @templates_root_path
end

#themeObject (readonly)

Returns the value of attribute theme.



5
6
7
# File 'app/components/maglev/page_component.rb', line 5

def theme
  @theme
end

Instance Method Details

#renderObject



28
29
30
# File 'app/components/maglev/page_component.rb', line 28

def render
  sections.collect(&:render).join
end

#sectionsObject

Sections within a dropzone



19
20
21
22
23
24
25
26
# File 'app/components/maglev/page_component.rb', line 19

def sections
  @sections ||= page_sections.map do |attributes|
    definition = theme.sections.find(attributes['type'])
    next unless definition

    build_section(definition, attributes)
  end.compact
end