Class: Locomotive::EditableText
- Inherits:
-
EditableElement
- Object
- EditableElement
- Locomotive::EditableText
- Defined in:
- app/models/locomotive/editable_text.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from EditableElement
#block_name, #block_priority, #label
Instance Method Summary collapse
-
#content ⇒ Object
fields ##.
-
#content=(value) ⇒ Object
methods ##.
- #content_from_default=(content) ⇒ Object
- #default_content? ⇒ Boolean
Methods inherited from EditableElement
#_type, #add_current_locale, #block_label, #by_priority, #disabled?, #page, #page_id, #path, #slug
Instance Method Details
#content ⇒ Object
fields ##
5 |
# File 'app/models/locomotive/editable_text.rb', line 5 field :content, localize: true |
#content=(value) ⇒ Object
methods ##
17 18 19 20 21 22 |
# File 'app/models/locomotive/editable_text.rb', line 17 def content=(value) return if value == self.content self.add_current_locale self.default_content = false unless self.new_record? super end |
#content_from_default=(content) ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/models/locomotive/editable_text.rb', line 28 def content_from_default=(content) if self.default_content? self.content_will_change! self.attributes['content'] ||= {} self.attributes['content'][::Mongoid::Fields::I18n.locale.to_s] = content end end |
#default_content? ⇒ Boolean
24 25 26 |
# File 'app/models/locomotive/editable_text.rb', line 24 def default_content? !!self.default_content end |