Sha256: c4026890971457bebb5da50cf4e4565ec8678bb43720d5a0a6e9a21ed6aac0b6

Contents?: true

Size: 900 Bytes

Versions: 2

Compression:

Stored size: 900 Bytes

Contents

module Landable
  class TemplateRevision < ActiveRecord::Base
    include Landable::TableName

    @@ignored_template_attributes = [
      'editable',
      'created_at',
      'updated_at',
      'published_revision_id',
      'file',
      'thumbnail_url',
      'is_layout',
      'is_publishable',
      'deleted_at'
    ]

    cattr_accessor :ignored_template_attributes

    belongs_to :template, inverse_of: :revisions
    belongs_to :author

    def template_id=(id)
      # set the value
      self[:template_id] = id

      # copy attributes from the template
      self.name          = template.name
      self.body          = template.body
      self.description   = template.description
      self.slug          = template.slug
    end

    def publish!
      update_attribute :is_published, true
    end

    def unpublish!
      update_attribute :is_published, false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.9.0.rc1 app/models/landable/template_revision.rb
landable-1.8.0 app/models/landable/template_revision.rb