Module: ActiveRecord::ConnectionAdapters::OracleEnhancedProcedures::InstanceMethods

Defined in:
lib/active_record/connection_adapters/oracle_enhanced_procedures.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/active_record/connection_adapters/oracle_enhanced_procedures.rb', line 101

def self.included(base)
  # alias methods just for ActiveRecord 2.x
  # for ActiveRecord 3.0 will just redefine create, update, delete methods which call super
  if ActiveRecord::VERSION::MAJOR < 3
    base.instance_eval do
      alias_method :create_without_custom_method, create_method_name_before_custom_methods
      alias_method create_method_name_before_custom_methods, :create_with_custom_method
      alias_method :update_without_custom_method, update_method_name_before_custom_methods
      alias_method update_method_name_before_custom_methods, :update_with_custom_method
      alias_method :destroy_without_custom_method, destroy_method_name_before_custom_methods
      alias_method destroy_method_name_before_custom_methods, :destroy_with_custom_method
      private :create, :update
      public :destroy
    end
  end
end

Instance Method Details

#destroyObject

:nodoc:



119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/active_record/connection_adapters/oracle_enhanced_procedures.rb', line 119

def destroy #:nodoc:
  # check if class has custom delete method
  if self.class.custom_delete_method
    # wrap destroy in transaction
    with_transaction_returning_status do
      # run before/after callbacks defined in model
      _run_destroy_callbacks { destroy_using_custom_method }
    end
  else
    super
  end
end