Class: Landable::PageDecorator
- Inherits:
-
Object
- Object
- Landable::PageDecorator
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- app/decorators/landable/page_decorator.rb
Direct Known Subclasses
Instance Method Summary collapse
- #body ⇒ Object
- #head_content ⇒ Object
-
#initialize(page) ⇒ PageDecorator
constructor
A new instance of PageDecorator.
- #meta_tags ⇒ Object
- #page_name ⇒ Object
- #path ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(page) ⇒ PageDecorator
Returns a new instance of PageDecorator.
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
#body ⇒ Object
22 23 24 |
# File 'app/decorators/landable/page_decorator.rb', line 22 def body page.body.try(:html_safe) end |
#head_content ⇒ Object
26 27 28 |
# File 'app/decorators/landable/page_decorator.rb', line 26 def head_content page.head_content.try(:html_safe) end |
#meta_tags ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/decorators/landable/page_decorator.rb', line 30 def return nil unless page. page..map { |name, value| tag('meta', name: name, content: value) if value.present? }.compact.join("\n").html_safe end |
#page_name ⇒ Object
18 19 20 |
# File 'app/decorators/landable/page_decorator.rb', line 18 def page_name page.page_name end |
#path ⇒ Object
14 15 16 |
# File 'app/decorators/landable/page_decorator.rb', line 14 def path page.path end |
#title ⇒ Object
10 11 12 |
# File 'app/decorators/landable/page_decorator.rb', line 10 def title content_tag('title', page.title) if page.title? end |