Class: BillyCms::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- BillyCms::Page
- Extended by:
- FriendlyId
- Includes:
- ActiveModel::Serialization
- Defined in:
- app/models/billy_cms/page.rb
Instance Method Summary collapse
- #additional_attribute(attribute_name) ⇒ Object
- #additional_attributes ⇒ Object
- #binaries ⇒ Object
- #binary? ⇒ Boolean
- #boxes ⇒ Object
- #children ⇒ Object
- #cms_path ⇒ Object
- #is_in_path?(path) ⇒ Boolean
- #navigation ⇒ Object
- #sibblings ⇒ Object
Instance Method Details
#additional_attribute(attribute_name) ⇒ Object
56 57 58 |
# File 'app/models/billy_cms/page.rb', line 56 def additional_attribute(attribute_name) self.additional_attributes_values[attribute_name.to_s] if self.additional_attributes_values.present? end |
#additional_attributes ⇒ Object
50 51 52 53 54 |
# File 'app/models/billy_cms/page.rb', line 50 def additional_attributes type = PageType.find_by_name(self.page_type) return [] unless type.present? type.additional_attributes end |
#binaries ⇒ Object
29 30 31 |
# File 'app/models/billy_cms/page.rb', line 29 def binaries pages.where(page_type: 'Binary').sort_by(&:order_key) end |
#binary? ⇒ Boolean
46 47 48 |
# File 'app/models/billy_cms/page.rb', line 46 def binary? self.page_type == 'Binary' end |
#boxes ⇒ Object
25 26 27 |
# File 'app/models/billy_cms/page.rb', line 25 def boxes pages.where(page_type: 'box').sort_by(&:order_key) end |
#children ⇒ Object
17 18 19 |
# File 'app/models/billy_cms/page.rb', line 17 def children pages.sort_by(&:order_key) end |
#cms_path ⇒ Object
13 14 15 |
# File 'app/models/billy_cms/page.rb', line 13 def cms_path get_cms_path_component_for_parent '', self end |
#is_in_path?(path) ⇒ Boolean
33 34 35 36 37 38 39 40 |
# File 'app/models/billy_cms/page.rb', line 33 def is_in_path?(path) if path == '/' return slug == 'startseite' ? true : false end # byebug if id == 6 reg = Regexp.new("^(#{cms_path})", 'i') path.match(reg) != nil end |
#navigation ⇒ Object
21 22 23 |
# File 'app/models/billy_cms/page.rb', line 21 def self.children.reject { |page| page. || page.page_type == 'Binary' || page.page_type == 'box' } end |
#sibblings ⇒ Object
42 43 44 |
# File 'app/models/billy_cms/page.rb', line 42 def sibblings self.class.where(parent_page_id: parent_page_id).where.not(id: id).order(:order_key) end |