Sha256: dc8e2041c5e53c36d330a61fbc48c13d0387092d852ccc62697cb3dd15e47cdb

Contents?: true

Size: 914 Bytes

Versions: 6

Compression:

Stored size: 914 Bytes

Contents

module DataMapper
  module Types
    module Paranoid
      module Base
        def self.included(model)
          model.extend ClassMethods
        end

        def paranoid_destroy
          model.paranoid_properties.each do |name, block|
            attribute_set(name, block.call(self))
          end
          save_self
          self.persisted_state = Resource::State::Immutable.new(self)
          true
        end

        private

        # @api private
        def _destroy(execute_hooks = true)
          return false unless saved?
          if execute_hooks
            paranoid_destroy
          else
            super
          end
        end
      end # module Base

      module ClassMethods
        def with_deleted
          with_exclusive_scope({}) { block_given? ? yield : all }
        end
      end # module ClassMethods
    end # module Paranoid
  end # module Types
end # module DataMapper

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dm-types-1.0.2 lib/dm-types/paranoid/base.rb
dm-types-1.0.1 lib/dm-types/paranoid/base.rb
dm-types-1.0.0 lib/dm-types/paranoid/base.rb
dm-types-1.0.0.rc3 lib/dm-types/paranoid/base.rb
dm-types-1.0.0.rc2 lib/dm-types/paranoid/base.rb
dm-types-1.0.0.rc1 lib/dm-types/paranoid/base.rb