Sha256: fc87f7ac999af47fd6f31dca235c4847e738e7208acf2680e78f3b2afcef3b8a

Contents?: true

Size: 889 Bytes

Versions: 7

Compression:

Stored size: 889 Bytes

Contents

# -*- encoding : utf-8 -*-
class Card::Revision < ActiveRecord::Base
  before_save :set_stamper

  class << self
    def cache
      Wagn::Cache[Card::Revision]
    end
    
    def delete_old
      where( Card.where( :current_revision_id=>arel_table[:id] ).exists.not ).delete_all
    end
    
    def delete_cardless
      where( Card.where( :id=>arel_table[:card_id] ).exists.not ).delete_all
    end
  end

  def set_stamper
    self.creator_id = Account.current_id
  end

  def creator
    Card[ creator_id ]
  end

  def card
    Card[ card_id ]
  end

  def title #ENGLISH
    current_id = card.current_revision_id
    if id == current_id
      'Current Revision'
    elsif id > current_id
      'AutoSave'
    else
      card.revisions.each_with_index do |rev, index|
        return "Revision ##{index + 1}" if rev.id == id
      end
      '[Revisions Missing]'
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wagn-1.12.13 lib/card/revision.rb
wagn-1.12.12 lib/card/revision.rb
wagn-1.12.11 lib/card/revision.rb
wagn-1.12.10 lib/card/revision.rb
wagn-1.12.9 app/models/card/revision.rb
wagn-1.12.8 app/models/card/revision.rb
wagn-1.12.7 app/models/card/revision.rb