Class: Para::SeoTools::Skeleton::Page
- Inherits:
-
Object
- Object
- Para::SeoTools::Skeleton::Page
- Defined in:
- lib/para/seo_tools/skeleton/page.rb
Instance Attribute Summary collapse
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #display_name ⇒ Object
- #identifier ⇒ Object
-
#initialize(name, path: nil, resource: nil, **options) ⇒ Page
constructor
A new instance of Page.
- #model ⇒ Object
- #path ⇒ Object
- #sitemap_options ⇒ Object
Constructor Details
#initialize(name, path: nil, resource: nil, **options) ⇒ Page
Returns a new instance of Page.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/para/seo_tools/skeleton/page.rb', line 9 def initialize(name, path: nil, resource: nil, **) @name = name @path = path @resource = resource = # Fetch locale on page build to allow calling the `page` skeleton # method inside a `I18n.with_locale` block # @locale = .fetch(:locale, I18n.locale) end |
Instance Attribute Details
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
7 8 9 |
# File 'lib/para/seo_tools/skeleton/page.rb', line 7 def locale @locale end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/para/seo_tools/skeleton/page.rb', line 7 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/para/seo_tools/skeleton/page.rb', line 7 def end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
7 8 9 |
# File 'lib/para/seo_tools/skeleton/page.rb', line 7 def resource @resource end |
Instance Method Details
#display_name ⇒ Object
25 26 27 |
# File 'lib/para/seo_tools/skeleton/page.rb', line 25 def display_name @display_name ||= [name, resource.try(:id)].compact.join(' #').humanize end |
#identifier ⇒ Object
21 22 23 |
# File 'lib/para/seo_tools/skeleton/page.rb', line 21 def identifier @identifier ||= [name, resource.try(:id)].compact.join(':') end |
#model ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/para/seo_tools/skeleton/page.rb', line 33 def model @model ||= self.class.model_for(identifier).tap do |page| # Override path (i.e.: slug changed) page.path = path if path.to_s != page.path page.locale = locale # Do not override meta tags if already present page.defaults = [:defaults] || {} end end |
#path ⇒ Object
29 30 31 |
# File 'lib/para/seo_tools/skeleton/page.rb', line 29 def path @path ||= find_route end |
#sitemap_options ⇒ Object
43 44 45 46 47 |
# File 'lib/para/seo_tools/skeleton/page.rb', line 43 def [:priority, :change_frequency].each_with_object({}) do |param, hash| hash[param] = [param] if .key?(param) end end |