Class: Locomotive::Steam::EditableElement
- Inherits:
-
Object
- Object
- Locomotive::Steam::EditableElement
- Includes:
- Models::Entity
- Defined in:
- lib/locomotive/steam/entities/editable_element.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
Returns the value of attribute page.
Attributes included from Models::Entity
#associations, #attributes, #base_url, #localized_attributes
Instance Method Summary collapse
- #content ⇒ Object
- #format ⇒ Object
-
#initialize(attributes = {}) ⇒ EditableElement
constructor
A new instance of EditableElement.
- #source ⇒ Object
Methods included from Models::Entity
#[], #[]=, #_id, #change, #method_missing, #respond_to?, #serialize
Methods included from Models::Concerns::ToJson
Methods included from Models::Concerns::Validation
Constructor Details
#initialize(attributes = {}) ⇒ EditableElement
Returns a new instance of EditableElement.
9 10 11 12 13 14 15 16 17 |
# File 'lib/locomotive/steam/entities/editable_element.rb', line 9 def initialize(attributes = {}) super({ label: nil, block: nil, content: nil, source: nil, inline_editing: true }.merge(attributes)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Locomotive::Steam::Models::Entity
Instance Attribute Details
#page ⇒ Object
Returns the value of attribute page.
7 8 9 |
# File 'lib/locomotive/steam/entities/editable_element.rb', line 7 def page @page end |
Instance Method Details
#content ⇒ Object
23 24 25 |
# File 'lib/locomotive/steam/entities/editable_element.rb', line 23 def content self[:source].blank? ? self[:content] : self[:source] end |
#format ⇒ Object
27 28 29 |
# File 'lib/locomotive/steam/entities/editable_element.rb', line 27 def format self[:format] || 'html' # only editable_text elements end |
#source ⇒ Object
19 20 21 |
# File 'lib/locomotive/steam/entities/editable_element.rb', line 19 def source self[:source].blank? ? self.content : self[:source] end |