Sha256: 05450f8c85a5eb19f9364c609b3be9f8d2c6aebd61c3c228533ab2908ef5ba89

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

module DBViewCTI
  module Model
    module CTI
      module Destroy
        extend ActiveSupport::Concern

        # change destroy and delete methods to operate on most specialized object
        included do
          alias_method :destroy_without_cti, :destroy
          alias_method :destroy, :destroy_with_cti

          alias_method :delete_without_cti, :delete
          alias_method :delete, :delete_with_cti

          # destroy! seems te be defined in Rails 4
          if self.method_defined?(:destroy!)
            alias_method :destroy_without_cti!, :destroy!
            alias_method :destroy!, :destroy_with_cti!
          end
        end
        
        def destroy_with_cti
          specialize.destroy_without_cti
        end
        
        def destroy_with_cti!
          specialize.destroy_without_cti!
        end
        
        def delete_with_cti
          specialize.delete_without_cti
        end
        
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dbview_cti-0.2.3 lib/db_view_cti/model/cti/destroy.rb
dbview_cti-0.2.2 lib/db_view_cti/model/cti/destroy.rb