Class: Landable::Template
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Landable::Template
- Defined in:
- app/models/landable/template.rb
Instance Attribute Summary collapse
-
#temp_author ⇒ Object
attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #deactivate ⇒ Object
- #name=(val) ⇒ Object
- #partial? ⇒ Boolean
- #publish!(options) ⇒ Object
- #revert_to!(revision) ⇒ Object
Methods included from Librarian
Instance Attribute Details
#temp_author ⇒ Object
attributes
7 8 9 |
# File 'app/models/landable/template.rb', line 7 def @temp_author end |
Class Method Details
Instance Method Details
#deactivate ⇒ Object
21 22 23 24 25 |
# File 'app/models/landable/template.rb', line 21 def deactivate publish!(author_id: .id, notes: "This template has been trashed") super end |
#name=(val) ⇒ Object
27 28 29 30 |
# File 'app/models/landable/template.rb', line 27 def name= val self[:name] = val self[:slug] ||= (val && val.underscore.gsub(/[^\w_]/, '_').gsub(/_{2,}/, '_')) end |
#partial? ⇒ Boolean
32 33 34 |
# File 'app/models/landable/template.rb', line 32 def partial? file.present? end |
#publish!(options) ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/models/landable/template.rb', line 36 def publish!() transaction do published_revision.unpublish! if published_revision revision = revisions.create! update_attributes!(published_revision: revision, is_publishable: false) end end |
#revert_to!(revision) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'app/models/landable/template.rb', line 44 def revert_to!(revision) self.name = revision.name self.body = revision.body self.description = revision.description self.slug = revision.slug save! end |