Module: ActiveRecord::OracleEnhancedProcedures

Defined in:
lib/active_record/connection_adapters/oracle_enhanced/procedures.rb

Overview

Custom create, update, delete methods functionality.

Example:

class Employee < ActiveRecord::Base
  include ActiveRecord::OracleEnhancedProcedures

  set_create_method do
    plsql.employees_pkg.create_employee(
      :p_first_name => first_name,
      :p_last_name => last_name,
      :p_employee_id => nil
    )[:p_employee_id]
  end

  set_update_method do
    plsql.employees_pkg.update_employee(
      :p_employee_id => id,
      :p_first_name => first_name,
      :p_last_name => last_name
    )
  end

  set_delete_method do
    plsql.employees_pkg.delete_employee(
      :p_employee_id => id
    )
  end
end

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/active_record/connection_adapters/oracle_enhanced/procedures.rb', line 77

def self.included(base)
  base.class_eval do
    extend ClassMethods
    class_attribute :custom_create_method
    class_attribute :custom_update_method
    class_attribute :custom_delete_method
  end
end

Instance Method Details

#destroyObject

:nodoc:



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/active_record/connection_adapters/oracle_enhanced/procedures.rb', line 86

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_callbacks(:destroy) { destroy_using_custom_method }
    end
  else
    super
  end
end