Sha256: 0be681cff82e249f1b84de89a9d829d9d543c8d7ca98c4b2b15a3fad2c678456

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

require 'peoplefinder'

class Peoplefinder::Version < PaperTrail::Version
  self.table_name = 'versions'

  def self.public_user
    'Public user'
  end

  def creation?
    event == 'create'
  end

  def destruction?
    event == 'destroy'
  end

  def alteration?
    event == 'update'
  end

  def membership?
    item_type == 'Peoplefinder::Membership'
  end

  def undo
    return if membership?
    creation? ? item.destroy : reify.save
  end

  def event_description
    if creation?
      "New #{ item_type }"

    elsif destruction?
      "Deleted #{ item_type }"

    elsif alteration?
      "#{ item_type } Edited"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
peoplefinder-0.1.1 app/models/peoplefinder/version.rb
peoplefinder-0.1.0 app/models/peoplefinder/version.rb