Sha256: a4699e1a08f7392ead0b8654ef5f5ce252dd7ebfe0d86c29d2821ca3bab99d35

Contents?: true

Size: 266 Bytes

Versions: 3

Compression:

Stored size: 266 Bytes

Contents

class Draft < ActiveRecord::Base
  belongs_to :user
  belongs_to :parent, polymorphic: true

  validates_presence_of :data, :target_type

  def restore
    target_type.constantize.from_draft(self)
  end

  def self.restore_all
    find_each.map(&:restore)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
drafting-0.4.2 lib/drafting/draft.rb
drafting-0.4.1 lib/drafting/draft.rb
drafting-0.4.0 lib/drafting/draft.rb