Module: Cms::Concerns::Addressable::ClassMethods
- Defined in:
- lib/cms/concerns/can_be_addressable.rb
Instance Method Summary collapse
-
#addressable? ⇒ Boolean
Once is_addressable is called, this will always be true.
-
#base_path ⇒ Object
Used in UI forms to show what the complete URL will look like with a slug added to it.
- #calculate_path(slug) ⇒ Object
-
#layout ⇒ String
Returns the layout (Page Template) that should be used to render instances of this content.
-
#path ⇒ String
The base path where new records will be added.
- #requires_slug? ⇒ Boolean
-
#with_slug(slug) ⇒ Addressable
Find an addressable object with the given content type.
Instance Method Details
#addressable? ⇒ Boolean
Returns Once is_addressable is called, this will always be true.
118 119 120 |
# File 'lib/cms/concerns/can_be_addressable.rb', line 118 def addressable? true end |
#base_path ⇒ Object
Used in UI forms to show what the complete URL will look like with a slug added to it.
127 128 129 |
# File 'lib/cms/concerns/can_be_addressable.rb', line 127 def base_path "#{self.path}/" end |
#calculate_path(slug) ⇒ Object
122 123 124 |
# File 'lib/cms/concerns/can_be_addressable.rb', line 122 def calculate_path(slug) "#{self.path}/#{slug}" end |
#layout ⇒ String
Returns the layout (Page Template) that should be used to render instances of this content. Can be specified as is_addressable template: ‘subpage’
143 144 145 |
# File 'lib/cms/concerns/can_be_addressable.rb', line 143 def layout normalize_layout(self, @template) end |
#path ⇒ String
The base path where new records will be added.
113 114 115 |
# File 'lib/cms/concerns/can_be_addressable.rb', line 113 def path @path end |
#requires_slug? ⇒ Boolean
107 108 109 |
# File 'lib/cms/concerns/can_be_addressable.rb', line 107 def requires_slug? !@path.nil? end |
#with_slug(slug) ⇒ Addressable
Find an addressable object with the given content type.
135 136 137 138 |
# File 'lib/cms/concerns/can_be_addressable.rb', line 135 def with_slug(slug) section_node = SectionNode.where(slug: slug).where(node_type: self.name).first section_node ? section_node.node : nil end |