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 app/concerns/oh_noes.rb
artfully_ose-1.2.0.beta.1 app/concerns/oh_noes.rb
artfully_ose-1.2.0.alpha.2 app/concerns/oh_noes.rb
artfully_ose-1.2.0.alpha.1 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.27 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.26 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.24 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.23 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.21 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.20 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.19 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.18 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.17 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.16 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.15 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.12 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.11 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.10 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.9 app/concerns/oh_noes.rb
artfully_ose-1.2.0.pre.8 app/concerns/oh_noes.rb