Class: Locomotive::EditableElement
- Inherits:
-
Object
- Object
- Locomotive::EditableElement
- Includes:
- Mongoid::Document
- Defined in:
- app/models/locomotive/editable_element.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#block_name ⇒ Object
non-persisted attributes ##.
-
#block_priority ⇒ Object
non-persisted attributes ##.
-
#label ⇒ Object
methods ##.
Instance Method Summary collapse
- #_type ⇒ Object
-
#add_current_locale ⇒ Object
Make sure the current locale is added to the list of locales for the current element so that we know in which languages the element was translated.
- #block_label ⇒ Object
-
#by_priority ⇒ Object
scopes ##.
- #disabled? ⇒ Boolean
-
#page ⇒ Object
associations ##.
- #page_id ⇒ Object
- #path ⇒ Object
-
#slug ⇒ Object
validations ##.
Instance Attribute Details
#block_name ⇒ Object
non-persisted attributes ##
30 31 32 |
# File 'app/models/locomotive/editable_element.rb', line 30 def block_name @block_name end |
#block_priority ⇒ Object
non-persisted attributes ##
30 31 32 |
# File 'app/models/locomotive/editable_element.rb', line 30 def block_priority @block_priority end |
#label ⇒ Object
methods ##
30 31 32 |
# File 'app/models/locomotive/editable_element.rb', line 30 def label @label end |
Instance Method Details
#_type ⇒ Object
50 51 52 |
# File 'app/models/locomotive/editable_element.rb', line 50 def _type nil end |
#add_current_locale ⇒ Object
Make sure the current locale is added to the list of locales for the current element so that we know in which languages the element was translated.
62 63 64 65 |
# File 'app/models/locomotive/editable_element.rb', line 62 def add_current_locale locale = ::Mongoid::Fields::I18n.locale.to_s self.locales << locale unless self.locales.include?(locale) end |
#block_label ⇒ Object
38 39 40 |
# File 'app/models/locomotive/editable_element.rb', line 38 def block_label (@block_name || self.block).try(:humanize) end |
#by_priority ⇒ Object
scopes ##
26 |
# File 'app/models/locomotive/editable_element.rb', line 26 scope :by_priority, -> { order_by(priority: :desc) } |
#disabled? ⇒ Boolean
46 47 48 |
# File 'app/models/locomotive/editable_element.rb', line 46 def disabled? !!self.disabled # the original method does not work quite well with the localization end |
#page ⇒ Object
associations ##
18 |
# File 'app/models/locomotive/editable_element.rb', line 18 :page, class_name: 'Locomotive::Page', inverse_of: :editable_elements |
#page_id ⇒ Object
54 55 56 |
# File 'app/models/locomotive/editable_element.rb', line 54 def page_id self._parent.try(:_id) end |
#path ⇒ Object
42 43 44 |
# File 'app/models/locomotive/editable_element.rb', line 42 def path [block, slug].compact.join('--').gsub('/', '--') end |
#slug ⇒ Object
validations ##
7 |
# File 'app/models/locomotive/editable_element.rb', line 7 field :slug |