Class: Landable::PageDecorator

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
app/decorators/landable/page_decorator.rb

Direct Known Subclasses

NullPageDecorator

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ PageDecorator

Returns a new instance of PageDecorator.

Raises:

  • (TypeError)


5
6
7
8
# File 'app/decorators/landable/page_decorator.rb', line 5

def initialize(page)
  raise TypeError.new("Use Landable::NullPageDecorator") if page.nil?
  @page = page
end

Instance Method Details

#bodyObject



22
23
24
# File 'app/decorators/landable/page_decorator.rb', line 22

def body
  page.body.try(:html_safe)
end

#head_contentObject



26
27
28
# File 'app/decorators/landable/page_decorator.rb', line 26

def head_content
  page.head_content.try(:html_safe)
end

#meta_tagsObject



30
31
32
33
34
35
36
# File 'app/decorators/landable/page_decorator.rb', line 30

def meta_tags
  return nil unless page.meta_tags?

  page.meta_tags.map { |name, value|
    tag('meta', name: name, content: value) if value.present?
  }.compact.join("\n").html_safe
end

#page_nameObject



18
19
20
# File 'app/decorators/landable/page_decorator.rb', line 18

def page_name
  page.page_name
end

#pathObject



14
15
16
# File 'app/decorators/landable/page_decorator.rb', line 14

def path
  page.path
end

#titleObject



10
11
12
# File 'app/decorators/landable/page_decorator.rb', line 10

def title
  ('title', page.title) if page.title?
end