activerecord-oracle_enhanced-adapter 1.4.3 → 1.5.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile +4 -14
 - data/History.md +51 -0
 - data/README.md +32 -1
 - data/VERSION +1 -1
 - data/activerecord-oracle_enhanced-adapter.gemspec +2 -4
 - data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +315 -57
 - data/lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb +55 -0
 - data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +4 -13
 - data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +5 -6
 - data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +19 -11
 - data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +163 -232
 - data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +18 -10
 - data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +20 -32
 - data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +54 -35
 - data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +5 -74
 - data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +3 -2
 - data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +98 -98
 - data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +5 -1
 - data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +3 -3
 - data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +11 -5
 - data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +56 -55
 - data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +15 -8
 - data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +4 -3
 - data/spec/spec_helper.rb +25 -54
 - metadata +32 -20
 - data/lib/active_record/connection_adapters/oracle_enhanced_activerecord_patches.rb +0 -41
 - data/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb +0 -121
 - data/lib/active_record/connection_adapters/oracle_enhanced_tasks.rb +0 -17
 
| 
         @@ -0,0 +1,55 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ActiveRecord #:nodoc:
         
     | 
| 
      
 2 
     | 
    
         
            +
              module ConnectionAdapters #:nodoc:
         
     | 
| 
      
 3 
     | 
    
         
            +
                module OracleEnhancedColumnDumper #:nodoc:
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  def self.included(base) #:nodoc:
         
     | 
| 
      
 6 
     | 
    
         
            +
                    base.class_eval do
         
     | 
| 
      
 7 
     | 
    
         
            +
                      private
         
     | 
| 
      
 8 
     | 
    
         
            +
                      alias_method_chain :column_spec,            :oracle_enhanced
         
     | 
| 
      
 9 
     | 
    
         
            +
                      alias_method_chain :prepare_column_options, :oracle_enhanced
         
     | 
| 
      
 10 
     | 
    
         
            +
                      alias_method_chain :migration_keys,         :oracle_enhanced
         
     | 
| 
      
 11 
     | 
    
         
            +
                    end
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def column_spec_with_oracle_enhanced(column, types)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    # return original method if not using 'OracleEnhanced'
         
     | 
| 
      
 16 
     | 
    
         
            +
                    if (rails_env = defined?(Rails.env) ? Rails.env : (defined?(RAILS_ENV) ? RAILS_ENV : nil)) &&
         
     | 
| 
      
 17 
     | 
    
         
            +
                          ActiveRecord::Base.configurations[rails_env] &&
         
     | 
| 
      
 18 
     | 
    
         
            +
                          ActiveRecord::Base.configurations[rails_env]['adapter'] != 'oracle_enhanced'
         
     | 
| 
      
 19 
     | 
    
         
            +
                      return column_spec_with_oracle_enhanced(column, types)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                    
         
     | 
| 
      
 22 
     | 
    
         
            +
                    spec = prepare_column_options(column, types)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    (spec.keys - [:name, :type]).each do |k|
         
     | 
| 
      
 24 
     | 
    
         
            +
                      key_s = (k == :virtual_type ? "type: " : "#{k.to_s}: ")
         
     | 
| 
      
 25 
     | 
    
         
            +
                      spec[k] = key_s + spec[k]
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
                    spec
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  def prepare_column_options_with_oracle_enhanced(column, types)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    spec = {}
         
     | 
| 
      
 32 
     | 
    
         
            +
                    spec[:name]      = column.name.inspect
         
     | 
| 
      
 33 
     | 
    
         
            +
                    spec[:type]      = column.virtual? ? 'virtual' : column.type.to_s
         
     | 
| 
      
 34 
     | 
    
         
            +
                    spec[:virtual_type] = column.type.inspect if column.virtual? && column.sql_type != 'NUMBER'
         
     | 
| 
      
 35 
     | 
    
         
            +
                    spec[:limit]     = column.limit.inspect if column.limit != types[column.type][:limit] && column.type != :decimal
         
     | 
| 
      
 36 
     | 
    
         
            +
                    spec[:precision] = column.precision.inspect if !column.precision.nil?
         
     | 
| 
      
 37 
     | 
    
         
            +
                    spec[:scale]     = column.scale.inspect if !column.scale.nil?
         
     | 
| 
      
 38 
     | 
    
         
            +
                    spec[:null]      = 'false' if !column.null
         
     | 
| 
      
 39 
     | 
    
         
            +
                    spec[:as]        = column.virtual_column_data_default if column.virtual?
         
     | 
| 
      
 40 
     | 
    
         
            +
                    spec[:default]   = default_string(column.default) if column.has_default? && !column.virtual?
         
     | 
| 
      
 41 
     | 
    
         
            +
                    spec
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                  def migration_keys_with_oracle_enhanced
         
     | 
| 
      
 45 
     | 
    
         
            +
                    # TODO `& column_specs.map(&:keys).flatten` should be exetuted here
         
     | 
| 
      
 46 
     | 
    
         
            +
                    [:name, :limit, :precision, :scale, :default, :null, :as, :virtual_type]
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
            end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            ActiveRecord::ConnectionAdapters::ColumnDumper.class_eval do
         
     | 
| 
      
 54 
     | 
    
         
            +
              include ActiveRecord::ConnectionAdapters::OracleEnhancedColumnDumper
         
     | 
| 
      
 55 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -329,19 +329,10 @@ module ActiveRecord 
     | 
|
| 
       329 
329 
     | 
    
         | 
| 
       330 
330 
     | 
    
         
             
                  module ContextIndexClassMethods
         
     | 
| 
       331 
331 
     | 
    
         
             
                    # Add context index condition.
         
     | 
| 
       332 
     | 
    
         
            -
                     
     | 
| 
       333 
     | 
    
         
            -
             
     | 
| 
       334 
     | 
    
         
            -
                       
     | 
| 
       335 
     | 
    
         
            -
                        score_label  
     | 
| 
       336 
     | 
    
         
            -
                        where("CONTAINS(#{connection.quote_column_name(column)}, ?, #{score_label}) > 0", query).
         
     | 
| 
       337 
     | 
    
         
            -
                          order("SCORE(#{score_label}) DESC")
         
     | 
| 
       338 
     | 
    
         
            -
                      end
         
     | 
| 
       339 
     | 
    
         
            -
                    when 2
         
     | 
| 
       340 
     | 
    
         
            -
                      def contains(column, query, options ={})
         
     | 
| 
       341 
     | 
    
         
            -
                        score_label = options[:label].to_i || 1
         
     | 
| 
       342 
     | 
    
         
            -
                        scoped(:conditions => ["CONTAINS(#{connection.quote_column_name(column)}, ?, #{score_label}) > 0", query],
         
     | 
| 
       343 
     | 
    
         
            -
                          :order => "SCORE(#{score_label}) DESC")
         
     | 
| 
       344 
     | 
    
         
            -
                      end
         
     | 
| 
      
 332 
     | 
    
         
            +
                    def contains(column, query, options ={})
         
     | 
| 
      
 333 
     | 
    
         
            +
                      score_label = options[:label].to_i || 1
         
     | 
| 
      
 334 
     | 
    
         
            +
                      where("CONTAINS(#{connection.quote_column_name(column)}, ?, #{score_label}) > 0", query).
         
     | 
| 
      
 335 
     | 
    
         
            +
                        order("SCORE(#{score_label}) DESC")
         
     | 
| 
       345 
336 
     | 
    
         
             
                    end
         
     | 
| 
       346 
337 
     | 
    
         
             
                  end
         
     | 
| 
       347 
338 
     | 
    
         | 
| 
         @@ -18,7 +18,7 @@ module ActiveRecord #:nodoc: 
     | 
|
| 
       18 
18 
     | 
    
         
             
                        # therefore need to convert empty string value to nil if old value is nil
         
     | 
| 
       19 
19 
     | 
    
         
             
                        elsif column.type == :string && column.null && old.nil?
         
     | 
| 
       20 
20 
     | 
    
         
             
                          value = nil if value == ''
         
     | 
| 
       21 
     | 
    
         
            -
                        elsif old == 0 && value.is_a?(String) && value.present? && value 
     | 
| 
      
 21 
     | 
    
         
            +
                        elsif old == 0 && value.is_a?(String) && value.present? && non_zero?(value)
         
     | 
| 
       22 
22 
     | 
    
         
             
                          value = nil
         
     | 
| 
       23 
23 
     | 
    
         
             
                        else
         
     | 
| 
       24 
24 
     | 
    
         
             
                          value = column.type_cast(value)
         
     | 
| 
         @@ -27,6 +27,10 @@ module ActiveRecord #:nodoc: 
     | 
|
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
                      old != value
         
     | 
| 
       29 
29 
     | 
    
         
             
                    end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                    def non_zero?(value)
         
     | 
| 
      
 32 
     | 
    
         
            +
                      value !~ /\A0+(\.0+)?\z/
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end 
         
     | 
| 
       30 
34 
     | 
    
         | 
| 
       31 
35 
     | 
    
         
             
                  end
         
     | 
| 
       32 
36 
     | 
    
         | 
| 
         @@ -37,10 +41,5 @@ end 
     | 
|
| 
       37 
41 
     | 
    
         
             
            if ActiveRecord::Base.method_defined?(:changed?)
         
     | 
| 
       38 
42 
     | 
    
         
             
              ActiveRecord::Base.class_eval do
         
     | 
| 
       39 
43 
     | 
    
         
             
                include ActiveRecord::ConnectionAdapters::OracleEnhancedDirty::InstanceMethods
         
     | 
| 
       40 
     | 
    
         
            -
                # Starting with rails 3.2.9 the method #field_changed?
         
     | 
| 
       41 
     | 
    
         
            -
                # was renamed to #_field_changed?
         
     | 
| 
       42 
     | 
    
         
            -
                if private_method_defined?(:field_changed?)
         
     | 
| 
       43 
     | 
    
         
            -
                  alias_method :field_changed?, :_field_changed?
         
     | 
| 
       44 
     | 
    
         
            -
                end
         
     | 
| 
       45 
44 
     | 
    
         
             
              end
         
     | 
| 
       46 
45 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,26 +2,34 @@ begin 
     | 
|
| 
       2 
2 
     | 
    
         
             
              require "java"
         
     | 
| 
       3 
3 
     | 
    
         
             
              require "jruby"
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
              # ojdbc6.jar or ojdbc5.jar file should be in  
     | 
| 
      
 5 
     | 
    
         
            +
              # ojdbc7.jar, ojdbc6.jar or ojdbc5.jar file should be in application ./lib directory or in load path or in ENV['PATH']
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
              java_version = java.lang.System.getProperty("java.version")
         
     | 
| 
       8 
     | 
    
         
            -
               
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
      
 8 
     | 
    
         
            +
              ojdbc_jars = if java_version =~ /^1.5/
         
     | 
| 
      
 9 
     | 
    
         
            +
                %w(ojdbc5.jar)
         
     | 
| 
       10 
10 
     | 
    
         
             
              elsif java_version =~ /^1.6/
         
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 11 
     | 
    
         
            +
                %w(ojdbc6.jar)
         
     | 
| 
       12 
12 
     | 
    
         
             
              elsif java_version =~ /^1.7/
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
      
 13 
     | 
    
         
            +
                # Oracle 11g client ojdbc6.jar is also compatible with Java 1.7
         
     | 
| 
      
 14 
     | 
    
         
            +
                # Oracle 12c client provides new ojdbc7.jar
         
     | 
| 
      
 15 
     | 
    
         
            +
                %w(ojdbc7.jar ojdbc6.jar)
         
     | 
| 
       14 
16 
     | 
    
         
             
              else
         
     | 
| 
       15 
17 
     | 
    
         
             
                nil
         
     | 
| 
       16 
18 
     | 
    
         
             
              end
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
               
     | 
| 
      
 20 
     | 
    
         
            +
              if ojdbc_jars && ENV_JAVA['java.class.path'] !~ Regexp.new(ojdbc_jars.join('|'))
         
     | 
| 
       19 
21 
     | 
    
         
             
                # On Unix environment variable should be PATH, on Windows it is sometimes Path
         
     | 
| 
       20 
22 
     | 
    
         
             
                env_path = (ENV["PATH"] || ENV["Path"] || '').split(File::PATH_SEPARATOR)
         
     | 
| 
       21 
23 
     | 
    
         
             
                # Look for JDBC driver at first in lib subdirectory (application specific JDBC file version)
         
     | 
| 
       22 
24 
     | 
    
         
             
                # then in Ruby load path and finally in environment PATH
         
     | 
| 
       23 
     | 
    
         
            -
                 
     | 
| 
       24 
     | 
    
         
            -
                   
     | 
| 
      
 25 
     | 
    
         
            +
                ['./lib'].concat($LOAD_PATH).concat(env_path).detect do |dir|
         
     | 
| 
      
 26 
     | 
    
         
            +
                  # check any compatible JDBC driver in the priority order
         
     | 
| 
      
 27 
     | 
    
         
            +
                  ojdbc_jars.any? do |ojdbc_jar|
         
     | 
| 
      
 28 
     | 
    
         
            +
                    if File.exists?(file_path = File.join(dir, ojdbc_jar))
         
     | 
| 
      
 29 
     | 
    
         
            +
                      require file_path
         
     | 
| 
      
 30 
     | 
    
         
            +
                      true
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
       25 
33 
     | 
    
         
             
                end
         
     | 
| 
       26 
34 
     | 
    
         
             
              end
         
     | 
| 
       27 
35 
     | 
    
         | 
| 
         @@ -35,7 +43,7 @@ begin 
     | 
|
| 
       35 
43 
     | 
    
         | 
| 
       36 
44 
     | 
    
         
             
            rescue LoadError, NameError
         
     | 
| 
       37 
45 
     | 
    
         
             
              # JDBC driver is unavailable.
         
     | 
| 
       38 
     | 
    
         
            -
              raise LoadError, "ERROR: ActiveRecord oracle_enhanced adapter could not load Oracle JDBC driver. Please install #{ 
     | 
| 
      
 46 
     | 
    
         
            +
              raise LoadError, "ERROR: ActiveRecord oracle_enhanced adapter could not load Oracle JDBC driver. Please install #{ojdbc_jars.join(' or ') || "Oracle JDBC"} library."
         
     | 
| 
       39 
47 
     | 
    
         
             
            end
         
     | 
| 
       40 
48 
     | 
    
         | 
| 
       41 
49 
     | 
    
         | 
| 
         @@ -88,7 +96,7 @@ module ActiveRecord 
     | 
|
| 
       88 
96 
     | 
    
         
             
                        @raw_connection = @raw_connection.innermost_delegate
         
     | 
| 
       89 
97 
     | 
    
         
             
                      elsif @raw_connection.respond_to?(:getUnderlyingConnection)
         
     | 
| 
       90 
98 
     | 
    
         
             
                        @pooled_connection = @raw_connection
         
     | 
| 
       91 
     | 
    
         
            -
                        @raw_connection = @raw_connection.underlying_connection 
     | 
| 
      
 99 
     | 
    
         
            +
                        @raw_connection = @raw_connection.underlying_connection
         
     | 
| 
       92 
100 
     | 
    
         
             
                      end
         
     | 
| 
       93 
101 
     | 
    
         | 
| 
       94 
102 
     | 
    
         
             
                      config[:driver] ||= @raw_connection.meta_data.connection.java_class.name
         
     | 
| 
         @@ -287,7 +295,7 @@ module ActiveRecord 
     | 
|
| 
       287 
295 
     | 
    
         
             
                        # else
         
     | 
| 
       288 
296 
     | 
    
         
             
                        #   nil
         
     | 
| 
       289 
297 
     | 
    
         
             
                        # end
         
     | 
| 
       290 
     | 
    
         
            -
             
     | 
| 
      
 298 
     | 
    
         
            +
             
     | 
| 
       291 
299 
     | 
    
         
             
                        # Workaround with CallableStatement
         
     | 
| 
       292 
300 
     | 
    
         
             
                        s = @raw_connection.prepareCall("BEGIN #{sql}; END;")
         
     | 
| 
       293 
301 
     | 
    
         
             
                        s.registerOutParameter(1, java.sql.Types::BIGINT)
         
     | 
| 
         @@ -1,260 +1,191 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # define accessors before requiring ruby-plsql as these accessors are used in clob writing callback and should be
         
     | 
| 
       2 
     | 
    
         
            -
            # available also if ruby-plsql could not be loaded
         
     | 
| 
       3 
     | 
    
         
            -
            ActiveRecord::Base.class_eval do
         
     | 
| 
       4 
     | 
    
         
            -
              if respond_to? :class_attribute
         
     | 
| 
       5 
     | 
    
         
            -
                class_attribute :custom_create_method, :custom_update_method, :custom_delete_method
         
     | 
| 
       6 
     | 
    
         
            -
              elsif respond_to? :class_inheritable_accessor
         
     | 
| 
       7 
     | 
    
         
            -
                class_inheritable_accessor :custom_create_method, :custom_update_method, :custom_delete_method
         
     | 
| 
       8 
     | 
    
         
            -
              end
         
     | 
| 
       9 
     | 
    
         
            -
            end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
1 
     | 
    
         
             
            require 'active_support'
         
     | 
| 
       12 
2 
     | 
    
         | 
| 
       13 
3 
     | 
    
         
             
            module ActiveRecord #:nodoc:
         
     | 
| 
       14 
     | 
    
         
            -
               
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                     
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                    if ActiveRecord::VERSION::MAJOR < 3
         
     | 
| 
       60 
     | 
    
         
            -
                      def create_method_name_before_custom_methods #:nodoc:
         
     | 
| 
       61 
     | 
    
         
            -
                        if private_method_defined?(:create_without_timestamps) && defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::STRING.to_f >= 2.3
         
     | 
| 
       62 
     | 
    
         
            -
                          :create_without_timestamps
         
     | 
| 
       63 
     | 
    
         
            -
                        elsif private_method_defined?(:create_without_callbacks)
         
     | 
| 
       64 
     | 
    
         
            -
                          :create_without_callbacks
         
     | 
| 
       65 
     | 
    
         
            -
                        else
         
     | 
| 
       66 
     | 
    
         
            -
                          :create
         
     | 
| 
       67 
     | 
    
         
            -
                        end
         
     | 
| 
       68 
     | 
    
         
            -
                      end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                      def update_method_name_before_custom_methods #:nodoc:
         
     | 
| 
       71 
     | 
    
         
            -
                        if private_method_defined?(:update_without_dirty)
         
     | 
| 
       72 
     | 
    
         
            -
                          :update_without_dirty
         
     | 
| 
       73 
     | 
    
         
            -
                        elsif private_method_defined?(:update_without_timestamps) && defined?(ActiveRecord::VERSION) && ActiveRecord::VERSION::STRING.to_f >= 2.3
         
     | 
| 
       74 
     | 
    
         
            -
                          :update_without_timestamps
         
     | 
| 
       75 
     | 
    
         
            -
                        elsif private_method_defined?(:update_without_callbacks)
         
     | 
| 
       76 
     | 
    
         
            -
                          :update_without_callbacks
         
     | 
| 
       77 
     | 
    
         
            -
                        else
         
     | 
| 
       78 
     | 
    
         
            -
                          :update
         
     | 
| 
       79 
     | 
    
         
            -
                        end
         
     | 
| 
       80 
     | 
    
         
            -
                      end
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Custom create, update, delete methods functionality.
         
     | 
| 
      
 5 
     | 
    
         
            +
              # 
         
     | 
| 
      
 6 
     | 
    
         
            +
              # Example:
         
     | 
| 
      
 7 
     | 
    
         
            +
              #
         
     | 
| 
      
 8 
     | 
    
         
            +
              #   class Employee < ActiveRecord::Base
         
     | 
| 
      
 9 
     | 
    
         
            +
              #     include ActiveRecord::OracleEnhancedProcedures
         
     | 
| 
      
 10 
     | 
    
         
            +
              #
         
     | 
| 
      
 11 
     | 
    
         
            +
              #     set_create_method do
         
     | 
| 
      
 12 
     | 
    
         
            +
              #       plsql.employees_pkg.create_employee(
         
     | 
| 
      
 13 
     | 
    
         
            +
              #         :p_first_name => first_name,
         
     | 
| 
      
 14 
     | 
    
         
            +
              #         :p_last_name => last_name,
         
     | 
| 
      
 15 
     | 
    
         
            +
              #         :p_employee_id => nil
         
     | 
| 
      
 16 
     | 
    
         
            +
              #       )[:p_employee_id]
         
     | 
| 
      
 17 
     | 
    
         
            +
              #     end
         
     | 
| 
      
 18 
     | 
    
         
            +
              #
         
     | 
| 
      
 19 
     | 
    
         
            +
              #     set_update_method do
         
     | 
| 
      
 20 
     | 
    
         
            +
              #       plsql.employees_pkg.update_employee(
         
     | 
| 
      
 21 
     | 
    
         
            +
              #         :p_employee_id => id,
         
     | 
| 
      
 22 
     | 
    
         
            +
              #         :p_first_name => first_name,
         
     | 
| 
      
 23 
     | 
    
         
            +
              #         :p_last_name => last_name
         
     | 
| 
      
 24 
     | 
    
         
            +
              #       )
         
     | 
| 
      
 25 
     | 
    
         
            +
              #     end
         
     | 
| 
      
 26 
     | 
    
         
            +
              #
         
     | 
| 
      
 27 
     | 
    
         
            +
              #     set_delete_method do
         
     | 
| 
      
 28 
     | 
    
         
            +
              #       plsql.employees_pkg.delete_employee(
         
     | 
| 
      
 29 
     | 
    
         
            +
              #         :p_employee_id => id
         
     | 
| 
      
 30 
     | 
    
         
            +
              #       )
         
     | 
| 
      
 31 
     | 
    
         
            +
              #     end
         
     | 
| 
      
 32 
     | 
    
         
            +
              #   end
         
     | 
| 
      
 33 
     | 
    
         
            +
              #
         
     | 
| 
      
 34 
     | 
    
         
            +
              module OracleEnhancedProcedures #:nodoc:
         
     | 
| 
      
 35 
     | 
    
         
            +
                module ClassMethods
         
     | 
| 
      
 36 
     | 
    
         
            +
                  # Specify custom create method which should be used instead of Rails generated INSERT statement.
         
     | 
| 
      
 37 
     | 
    
         
            +
                  # Provided block should return ID of new record.
         
     | 
| 
      
 38 
     | 
    
         
            +
                  # Example:
         
     | 
| 
      
 39 
     | 
    
         
            +
                  #   set_create_method do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  #     plsql.employees_pkg.create_employee(
         
     | 
| 
      
 41 
     | 
    
         
            +
                  #       :p_first_name => first_name,
         
     | 
| 
      
 42 
     | 
    
         
            +
                  #       :p_last_name => last_name,
         
     | 
| 
      
 43 
     | 
    
         
            +
                  #       :p_employee_id => nil
         
     | 
| 
      
 44 
     | 
    
         
            +
                  #     )[:p_employee_id]
         
     | 
| 
      
 45 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 46 
     | 
    
         
            +
                  def set_create_method(&block)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    self.custom_create_method = block
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
       81 
49 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
      
 50 
     | 
    
         
            +
                  # Specify custom update method which should be used instead of Rails generated UPDATE statement.
         
     | 
| 
      
 51 
     | 
    
         
            +
                  # Example:
         
     | 
| 
      
 52 
     | 
    
         
            +
                  #   set_update_method do
         
     | 
| 
      
 53 
     | 
    
         
            +
                  #     plsql.employees_pkg.update_employee(
         
     | 
| 
      
 54 
     | 
    
         
            +
                  #       :p_employee_id => id,
         
     | 
| 
      
 55 
     | 
    
         
            +
                  #       :p_first_name => first_name,
         
     | 
| 
      
 56 
     | 
    
         
            +
                  #       :p_last_name => last_name
         
     | 
| 
      
 57 
     | 
    
         
            +
                  #     )
         
     | 
| 
      
 58 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 59 
     | 
    
         
            +
                  def set_update_method(&block)
         
     | 
| 
      
 60 
     | 
    
         
            +
                    self.custom_update_method = block
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
       90 
62 
     | 
    
         | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
      
 63 
     | 
    
         
            +
                  # Specify custom delete method which should be used instead of Rails generated DELETE statement.
         
     | 
| 
      
 64 
     | 
    
         
            +
                  # Example:
         
     | 
| 
      
 65 
     | 
    
         
            +
                  #   set_delete_method do
         
     | 
| 
      
 66 
     | 
    
         
            +
                  #     plsql.employees_pkg.delete_employee(
         
     | 
| 
      
 67 
     | 
    
         
            +
                  #       :p_employee_id => id
         
     | 
| 
      
 68 
     | 
    
         
            +
                  #     )
         
     | 
| 
      
 69 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 70 
     | 
    
         
            +
                  def set_delete_method(&block)
         
     | 
| 
      
 71 
     | 
    
         
            +
                    self.custom_delete_method = block
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
       92 
74 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                     
     | 
| 
      
 75 
     | 
    
         
            +
                def self.included(base)
         
     | 
| 
      
 76 
     | 
    
         
            +
                  base.class_eval do
         
     | 
| 
      
 77 
     | 
    
         
            +
                    extend ClassMethods
         
     | 
| 
      
 78 
     | 
    
         
            +
                    class_attribute :custom_create_method
         
     | 
| 
      
 79 
     | 
    
         
            +
                    class_attribute :custom_update_method
         
     | 
| 
      
 80 
     | 
    
         
            +
                    class_attribute :custom_delete_method
         
     | 
| 
       98 
81 
     | 
    
         
             
                  end
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
       99 
83 
     | 
    
         | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
                          alias_method create_method_name_before_custom_methods, :create_with_custom_method
         
     | 
| 
       108 
     | 
    
         
            -
                          alias_method :update_without_custom_method, update_method_name_before_custom_methods
         
     | 
| 
       109 
     | 
    
         
            -
                          alias_method update_method_name_before_custom_methods, :update_with_custom_method
         
     | 
| 
       110 
     | 
    
         
            -
                          alias_method :destroy_without_custom_method, destroy_method_name_before_custom_methods
         
     | 
| 
       111 
     | 
    
         
            -
                          alias_method destroy_method_name_before_custom_methods, :destroy_with_custom_method
         
     | 
| 
       112 
     | 
    
         
            -
                          private :create, :update
         
     | 
| 
       113 
     | 
    
         
            -
                          public :destroy
         
     | 
| 
       114 
     | 
    
         
            -
                        end
         
     | 
| 
       115 
     | 
    
         
            -
                      end
         
     | 
| 
      
 84 
     | 
    
         
            +
                def destroy #:nodoc:
         
     | 
| 
      
 85 
     | 
    
         
            +
                  # check if class has custom delete method
         
     | 
| 
      
 86 
     | 
    
         
            +
                  if self.class.custom_delete_method
         
     | 
| 
      
 87 
     | 
    
         
            +
                    # wrap destroy in transaction
         
     | 
| 
      
 88 
     | 
    
         
            +
                    with_transaction_returning_status do
         
     | 
| 
      
 89 
     | 
    
         
            +
                      # run before/after callbacks defined in model
         
     | 
| 
      
 90 
     | 
    
         
            +
                      run_callbacks(:destroy) { destroy_using_custom_method }
         
     | 
| 
       116 
91 
     | 
    
         
             
                    end
         
     | 
| 
      
 92 
     | 
    
         
            +
                  else
         
     | 
| 
      
 93 
     | 
    
         
            +
                    super
         
     | 
| 
      
 94 
     | 
    
         
            +
                  end
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
       117 
96 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 97 
     | 
    
         
            +
                private
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                # Creates a record with custom create method
         
     | 
| 
      
 100 
     | 
    
         
            +
                # and returns its id.
         
     | 
| 
      
 101 
     | 
    
         
            +
                def create_record
         
     | 
| 
      
 102 
     | 
    
         
            +
                  # check if class has custom create method
         
     | 
| 
      
 103 
     | 
    
         
            +
                  if self.class.custom_create_method
         
     | 
| 
      
 104 
     | 
    
         
            +
                    # run before/after callbacks defined in model
         
     | 
| 
      
 105 
     | 
    
         
            +
                    run_callbacks(:create) do
         
     | 
| 
      
 106 
     | 
    
         
            +
                      # timestamp
         
     | 
| 
      
 107 
     | 
    
         
            +
                      if self.record_timestamps
         
     | 
| 
      
 108 
     | 
    
         
            +
                        current_time = current_time_from_proper_timezone
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                        all_timestamp_attributes.each do |column|
         
     | 
| 
      
 111 
     | 
    
         
            +
                          if respond_to?(column) && respond_to?("#{column}=") && self.send(column).nil?
         
     | 
| 
      
 112 
     | 
    
         
            +
                            write_attribute(column.to_s, current_time)
         
     | 
| 
       126 
113 
     | 
    
         
             
                          end
         
     | 
| 
       127 
     | 
    
         
            -
                        else
         
     | 
| 
       128 
     | 
    
         
            -
                          super
         
     | 
| 
       129 
     | 
    
         
            -
                        end
         
     | 
| 
       130 
     | 
    
         
            -
                      end
         
     | 
| 
       131 
     | 
    
         
            -
                    end
         
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
                    private
         
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
                    # Creates a record with custom create method
         
     | 
| 
       136 
     | 
    
         
            -
                    # and returns its id.
         
     | 
| 
       137 
     | 
    
         
            -
                    if ActiveRecord::VERSION::MAJOR < 3
         
     | 
| 
       138 
     | 
    
         
            -
                      def create_with_custom_method
         
     | 
| 
       139 
     | 
    
         
            -
                        # check if class has custom create method
         
     | 
| 
       140 
     | 
    
         
            -
                        self.class.custom_create_method ? create_using_custom_method : create_without_custom_method
         
     | 
| 
       141 
     | 
    
         
            -
                      end
         
     | 
| 
       142 
     | 
    
         
            -
                    else # ActiveRecord 3.x
         
     | 
| 
       143 
     | 
    
         
            -
                      def create
         
     | 
| 
       144 
     | 
    
         
            -
                        # check if class has custom create method
         
     | 
| 
       145 
     | 
    
         
            -
                        if self.class.custom_create_method
         
     | 
| 
       146 
     | 
    
         
            -
                          set_timestamps_before_custom_create_method
         
     | 
| 
       147 
     | 
    
         
            -
                          # run before/after callbacks defined in model
         
     | 
| 
       148 
     | 
    
         
            -
                          _run_create_callbacks { create_using_custom_method }
         
     | 
| 
       149 
     | 
    
         
            -
                        else
         
     | 
| 
       150 
     | 
    
         
            -
                          super
         
     | 
| 
       151 
114 
     | 
    
         
             
                        end
         
     | 
| 
       152 
115 
     | 
    
         
             
                      end
         
     | 
| 
      
 116 
     | 
    
         
            +
                      # run
         
     | 
| 
      
 117 
     | 
    
         
            +
                      create_using_custom_method
         
     | 
| 
       153 
118 
     | 
    
         
             
                    end
         
     | 
| 
      
 119 
     | 
    
         
            +
                  else
         
     | 
| 
      
 120 
     | 
    
         
            +
                    super
         
     | 
| 
      
 121 
     | 
    
         
            +
                  end
         
     | 
| 
      
 122 
     | 
    
         
            +
                end
         
     | 
| 
       154 
123 
     | 
    
         | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
      
 124 
     | 
    
         
            +
                def create_using_custom_method
         
     | 
| 
      
 125 
     | 
    
         
            +
                  log_custom_method("custom create method", "#{self.class.name} Create") do
         
     | 
| 
      
 126 
     | 
    
         
            +
                    self.id = instance_eval(&self.class.custom_create_method)
         
     | 
| 
      
 127 
     | 
    
         
            +
                  end
         
     | 
| 
      
 128 
     | 
    
         
            +
                  @new_record = false
         
     | 
| 
      
 129 
     | 
    
         
            +
                  # Starting from ActiveRecord 3.0.3 @persisted is used instead of @new_record
         
     | 
| 
      
 130 
     | 
    
         
            +
                  @persisted = true
         
     | 
| 
      
 131 
     | 
    
         
            +
                  id
         
     | 
| 
      
 132 
     | 
    
         
            +
                end
         
     | 
| 
       164 
133 
     | 
    
         | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
                       
     | 
| 
       174 
     | 
    
         
            -
                         
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
                           
     | 
| 
       178 
     | 
    
         
            -
                           
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
       180 
     | 
    
         
            -
                            if partial_updates?
         
     | 
| 
       181 
     | 
    
         
            -
                              # Serialized attributes should always be written in case they've been
         
     | 
| 
       182 
     | 
    
         
            -
                              # changed in place.
         
     | 
| 
       183 
     | 
    
         
            -
                              update_using_custom_method(changed | (attributes.keys & self.class.serialized_attributes.keys))
         
     | 
| 
       184 
     | 
    
         
            -
                            else
         
     | 
| 
       185 
     | 
    
         
            -
                              update_using_custom_method(attribute_names)
         
     | 
| 
       186 
     | 
    
         
            -
                            end
         
     | 
| 
       187 
     | 
    
         
            -
                          end
         
     | 
| 
       188 
     | 
    
         
            -
                        else
         
     | 
| 
       189 
     | 
    
         
            -
                          super
         
     | 
| 
      
 134 
     | 
    
         
            +
                # Updates the associated record with custom update method
         
     | 
| 
      
 135 
     | 
    
         
            +
                # Returns the number of affected rows.
         
     | 
| 
      
 136 
     | 
    
         
            +
                def update_record(attribute_names = @attributes.keys)
         
     | 
| 
      
 137 
     | 
    
         
            +
                  # check if class has custom update method
         
     | 
| 
      
 138 
     | 
    
         
            +
                  if self.class.custom_update_method
         
     | 
| 
      
 139 
     | 
    
         
            +
                    # run before/after callbacks defined in model
         
     | 
| 
      
 140 
     | 
    
         
            +
                    run_callbacks(:update) do
         
     | 
| 
      
 141 
     | 
    
         
            +
                      # timestamp
         
     | 
| 
      
 142 
     | 
    
         
            +
                      if should_record_timestamps?
         
     | 
| 
      
 143 
     | 
    
         
            +
                        current_time = current_time_from_proper_timezone
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
                        timestamp_attributes_for_update_in_model.each do |column|
         
     | 
| 
      
 146 
     | 
    
         
            +
                          column = column.to_s
         
     | 
| 
      
 147 
     | 
    
         
            +
                          next if attribute_changed?(column)
         
     | 
| 
      
 148 
     | 
    
         
            +
                          write_attribute(column, current_time)
         
     | 
| 
       190 
149 
     | 
    
         
             
                        end
         
     | 
| 
       191 
150 
     | 
    
         
             
                      end
         
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
             
     | 
| 
       195 
     | 
    
         
            -
             
     | 
| 
       196 
     | 
    
         
            -
             
     | 
| 
       197 
     | 
    
         
            -
             
     | 
| 
       198 
     | 
    
         
            -
             
     | 
| 
       199 
     | 
    
         
            -
                      1
         
     | 
| 
       200 
     | 
    
         
            -
                    end
         
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
                    # Deletes the record in the database with custom delete method
         
     | 
| 
       203 
     | 
    
         
            -
                    # and freezes this instance to reflect that no changes should
         
     | 
| 
       204 
     | 
    
         
            -
                    # be made (since they can't be persisted).
         
     | 
| 
       205 
     | 
    
         
            -
                    if ActiveRecord::VERSION::MAJOR < 3
         
     | 
| 
       206 
     | 
    
         
            -
                      def destroy_with_custom_method
         
     | 
| 
       207 
     | 
    
         
            -
                        # check if class has custom delete method
         
     | 
| 
       208 
     | 
    
         
            -
                        self.class.custom_delete_method ? destroy_using_custom_method : destroy_without_custom_method
         
     | 
| 
      
 151 
     | 
    
         
            +
                      # update just dirty attributes
         
     | 
| 
      
 152 
     | 
    
         
            +
                      if partial_writes?
         
     | 
| 
      
 153 
     | 
    
         
            +
                        # Serialized attributes should always be written in case they've been
         
     | 
| 
      
 154 
     | 
    
         
            +
                        # changed in place.
         
     | 
| 
      
 155 
     | 
    
         
            +
                        update_using_custom_method(changed | (attributes.keys & self.class.serialized_attributes.keys))
         
     | 
| 
      
 156 
     | 
    
         
            +
                      else
         
     | 
| 
      
 157 
     | 
    
         
            +
                        update_using_custom_method(attribute_names)
         
     | 
| 
       209 
158 
     | 
    
         
             
                      end
         
     | 
| 
       210 
159 
     | 
    
         
             
                    end
         
     | 
| 
      
 160 
     | 
    
         
            +
                  else
         
     | 
| 
      
 161 
     | 
    
         
            +
                    super
         
     | 
| 
      
 162 
     | 
    
         
            +
                  end
         
     | 
| 
      
 163 
     | 
    
         
            +
                end
         
     | 
| 
       211 
164 
     | 
    
         | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
       213 
     | 
    
         
            -
             
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
       216 
     | 
    
         
            -
             
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
       218 
     | 
    
         
            -
             
     | 
| 
       219 
     | 
    
         
            -
                      @destroyed = true
         
     | 
| 
       220 
     | 
    
         
            -
                      freeze
         
     | 
| 
       221 
     | 
    
         
            -
                    end
         
     | 
| 
       222 
     | 
    
         
            -
             
     | 
| 
       223 
     | 
    
         
            -
                    if ActiveRecord::VERSION::MAJOR >= 3
         
     | 
| 
       224 
     | 
    
         
            -
                      def set_timestamps_before_custom_create_method
         
     | 
| 
       225 
     | 
    
         
            -
                        if record_timestamps
         
     | 
| 
       226 
     | 
    
         
            -
                          current_time = current_time_from_proper_timezone
         
     | 
| 
       227 
     | 
    
         
            -
             
     | 
| 
       228 
     | 
    
         
            -
                          write_attribute('created_at', current_time) if respond_to?(:created_at) && created_at.nil?
         
     | 
| 
       229 
     | 
    
         
            -
                          write_attribute('created_on', current_time) if respond_to?(:created_on) && created_on.nil?
         
     | 
| 
       230 
     | 
    
         
            -
             
     | 
| 
       231 
     | 
    
         
            -
                          write_attribute('updated_at', current_time) if respond_to?(:updated_at) && updated_at.nil?
         
     | 
| 
       232 
     | 
    
         
            -
                          write_attribute('updated_on', current_time) if respond_to?(:updated_on) && updated_on.nil?
         
     | 
| 
       233 
     | 
    
         
            -
                        end
         
     | 
| 
       234 
     | 
    
         
            -
                      end
         
     | 
| 
       235 
     | 
    
         
            -
             
     | 
| 
       236 
     | 
    
         
            -
                      def set_timestamps_before_custom_update_method
         
     | 
| 
       237 
     | 
    
         
            -
                        if record_timestamps && (!partial_updates? || changed?)
         
     | 
| 
       238 
     | 
    
         
            -
                          current_time = current_time_from_proper_timezone
         
     | 
| 
      
 165 
     | 
    
         
            +
                def update_using_custom_method(attribute_names)
         
     | 
| 
      
 166 
     | 
    
         
            +
                  return 0 if attribute_names.empty?
         
     | 
| 
      
 167 
     | 
    
         
            +
                  log_custom_method("custom update method with #{self.class.primary_key}=#{self.id}", "#{self.class.name} Update") do
         
     | 
| 
      
 168 
     | 
    
         
            +
                    instance_eval(&self.class.custom_update_method)
         
     | 
| 
      
 169 
     | 
    
         
            +
                  end
         
     | 
| 
      
 170 
     | 
    
         
            +
                  1
         
     | 
| 
      
 171 
     | 
    
         
            +
                end
         
     | 
| 
       239 
172 
     | 
    
         | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
             
     | 
| 
       242 
     | 
    
         
            -
             
     | 
| 
       243 
     | 
    
         
            -
             
     | 
| 
      
 173 
     | 
    
         
            +
                # Deletes the record in the database with custom delete method
         
     | 
| 
      
 174 
     | 
    
         
            +
                # and freezes this instance to reflect that no changes should
         
     | 
| 
      
 175 
     | 
    
         
            +
                # be made (since they can't be persisted).
         
     | 
| 
      
 176 
     | 
    
         
            +
                def destroy_using_custom_method
         
     | 
| 
      
 177 
     | 
    
         
            +
                  unless new_record? || @destroyed
         
     | 
| 
      
 178 
     | 
    
         
            +
                    log_custom_method("custom delete method with #{self.class.primary_key}=#{self.id}", "#{self.class.name} Destroy") do
         
     | 
| 
      
 179 
     | 
    
         
            +
                      instance_eval(&self.class.custom_delete_method)
         
     | 
| 
       244 
180 
     | 
    
         
             
                    end
         
     | 
| 
       245 
     | 
    
         
            -
             
     | 
| 
       246 
181 
     | 
    
         
             
                  end
         
     | 
| 
       247 
182 
     | 
    
         | 
| 
      
 183 
     | 
    
         
            +
                  @destroyed = true
         
     | 
| 
      
 184 
     | 
    
         
            +
                  freeze
         
     | 
| 
       248 
185 
     | 
    
         
             
                end
         
     | 
| 
       249 
     | 
    
         
            -
              end
         
     | 
| 
       250 
     | 
    
         
            -
            end
         
     | 
| 
       251 
186 
     | 
    
         | 
| 
       252 
     | 
    
         
            -
             
     | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
       254 
     | 
    
         
            -
            end
         
     | 
| 
       255 
     | 
    
         
            -
             
     | 
| 
       256 
     | 
    
         
            -
            ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.class_eval do
         
     | 
| 
       257 
     | 
    
         
            -
              # public alias to log method which could be used from other objects
         
     | 
| 
       258 
     | 
    
         
            -
              alias_method :log_custom_method, :log
         
     | 
| 
       259 
     | 
    
         
            -
              public :log_custom_method
         
     | 
| 
      
 187 
     | 
    
         
            +
                def log_custom_method(*args)
         
     | 
| 
      
 188 
     | 
    
         
            +
                  self.class.connection.send(:log, *args) { yield }
         
     | 
| 
      
 189 
     | 
    
         
            +
                end
         
     | 
| 
      
 190 
     | 
    
         
            +
              end
         
     | 
| 
       260 
191 
     | 
    
         
             
            end
         
     |