Sha256: 10a32e7dacffd628ec8b628fe441f5c1e7f343abf9bdb15b97cb2cc5438f4f68

Contents?: true

Size: 508 Bytes

Versions: 31

Compression:

Stored size: 508 Bytes

Contents

module OhNoes
  module Destroy
    extend ActiveSupport::Concern
    
    included do
      default_scope where(:deleted_at => nil)
    end
  
    # options:
    # :with_prejudice => true, will not check destroyable?
    delegate :destroy!, :to => :destroy
    def destroy(options = {})
      return false unless destroyable? || !!options[:with_prejudice]
      run_callbacks :destroy do
        update_column(:deleted_at, Time.now)
      end
    end
    
    def destroyable?
      true
    end
  
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.7 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.6 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.5 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.4 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.3 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.2 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.1 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre app/concerns/oh_noes.rb
artfully_ose-1.1.0 app/concerns/oh_noes.rb
artfully_ose-1.1.0.rc2 app/concerns/oh_noes.rb
artfully_ose-1.1.0.rc1 app/concerns/oh_noes.rb