Module: Katalyst::Content::Container
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/katalyst/content/container.rb
Instance Method Summary collapse
-
#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.
-
#state ⇒ Object
A resource is in draft mode if it has an unpublished draft or it has no published version.
Instance Method Details
#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.
78 79 80 |
# File 'app/models/concerns/katalyst/content/container.rb', line 78 def items_attributes=(attributes) next_version.nodes = attributes end |
#publish! ⇒ Object
Promotes the draft version to become the published version
62 63 64 65 |
# File 'app/models/concerns/katalyst/content/container.rb', line 62 def publish! update!(published_version: draft_version) self end |
#revert! ⇒ Object
Reverts the draft version to the current published version
68 69 70 71 |
# File 'app/models/concerns/katalyst/content/container.rb', line 68 def revert! update!(draft_version: published_version) self end |
#state ⇒ Object
A resource is in draft mode if it has an unpublished draft or it has no published version.
53 54 55 56 57 58 59 |
# File 'app/models/concerns/katalyst/content/container.rb', line 53 def state if published_version_id && published_version_id == draft_version_id :published else :draft end end |