Sha256: ca2f16d6031339994a5e7c17244e7fca322b938a45d551e540a649d3d70af613

Contents?: true

Size: 682 Bytes

Versions: 4

Compression:

Stored size: 682 Bytes

Contents

Gaku::Contact.class_eval do

  has_paper_trail class_name: 'Gaku::Versioning::ContactVersion',
                on: [:update, :destroy],
                meta: {
                        join_model: :join_model_name,
                        joined_resource_id: :joined_resource_id
                      }

  default_scope -> { where(deleted: false) }

  def soft_delete
    update_attributes(deleted: true, primary: false)
    decrement_count
  end

  def recover
    update_attribute(:deleted, false)
    increment_count
  end

  def self.deleted
    where(deleted: true)
  end

  def join_model_name
    contactable_type
  end

  def joined_resource_id
    contactable_id
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
gaku-0.1.1 archive/app/models/gaku/contact_injector.rb
gaku_archive-0.1.1 app/models/gaku/contact_injector.rb
gaku-0.1.0 archive/app/models/gaku/contact_injector.rb
gaku_archive-0.1.0 app/models/gaku/contact_injector.rb