Sha256: 02b14f7b183eb23aef2ae01ffefd49d4995698914ffba202ce8b963e7c2b66ea

Contents?: true

Size: 750 Bytes

Versions: 45

Compression:

Stored size: 750 Bytes

Contents

module Abstractor
  module Methods
    module Models
      module SoftDelete
        def self.included(base)
          attr_accessor :soft_delete
          base.send(:scope, :not_deleted, -> { base.where(:deleted_at => nil) })
        end

        def process_soft_delete
          self.deleted_at = Time.zone.now
        end

        def soft_delete=(removed)
          if (removed.is_a?(TrueClass) || removed.to_s == 't' || removed.to_s == '1')
            process_soft_delete
          end
        end

        def soft_delete
          !self.deleted_at.blank?
        end

        def soft_delete!
          process_soft_delete
          save!
        end

        def deleted?
          !deleted_at.blank?
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
abstractor-4.4.7 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.4.6 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.4.5 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.4.4 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.4.3 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.4.2 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.4.1 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.4.0 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.3.3 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.3.2 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.3.1 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.3.0 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.2.3 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.2.2 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.2.1 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.2.0 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.1.5 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.1.4 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.1.3 lib/abstractor/methods/models/soft_delete.rb
abstractor-4.1.2 lib/abstractor/methods/models/soft_delete.rb