Module: Katalyst::Content::Container
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/katalyst/content/container.rb
Instance Method Summary collapse
-
#items_attributes ⇒ Object
Required for testing items validation.
-
#items_attributes=(attributes) ⇒ Object
Updates the current draft version with new structure.
-
#publish! ⇒ Object
Promotes the draft version to become the published version.
-
#revert! ⇒ Object
Reverts the draft version to the current published version.
-
#unpublish! ⇒ Object
Sets the currently published version to nil.
Instance Method Details
#items_attributes ⇒ Object
Required for testing items validation
141 142 143 |
# File 'app/models/concerns/katalyst/content/container.rb', line 141 def items_attributes draft_version&.nodes&.as_json end |
#items_attributes=(attributes) ⇒ Object
Updates the current draft version with new structure. Attributes should be structural information about the items, e.g. ‘=> {id:, depth:` or `[depth:]`.
This method conforms to the behaviour of ‘accepts_nested_attributes_for` so that it can be used with rails form helpers.
150 151 152 |
# File 'app/models/concerns/katalyst/content/container.rb', line 150 def items_attributes=(attributes) next_version.nodes = attributes end |
#publish! ⇒ Object
Promotes the draft version to become the published version
123 124 125 126 |
# File 'app/models/concerns/katalyst/content/container.rb', line 123 def publish! update!(published_version: draft_version) self end |
#revert! ⇒ Object
Reverts the draft version to the current published version
129 130 131 132 |
# File 'app/models/concerns/katalyst/content/container.rb', line 129 def revert! update!(draft_version: published_version) self end |
#unpublish! ⇒ Object
Sets the currently published version to nil
135 136 137 138 |
# File 'app/models/concerns/katalyst/content/container.rb', line 135 def unpublish! update!(published_version_id: nil) self end |