Sha256: 174aedcb502277b16047406423bbc4cd7dde141dfcab4a915e06cf2d128918c4

Contents?: true

Size: 1.48 KB

Versions: 7

Compression:

Stored size: 1.48 KB

Contents

require "bigdecimal"
unless BigDecimal.instance_methods.include?("to_d")
  BigDecimal.class_eval do
    def to_d #:nodoc:
      self
    end
  end
end

unless Bignum.instance_methods.include?("to_d")
  Bignum.class_eval do
    def to_d #:nodoc:
      BigDecimal.new(self.to_s)
    end
  end
end

unless Fixnum.instance_methods.include?("to_d")
  Fixnum.class_eval do
    def to_d #:nodoc:
      BigDecimal.new(self.to_s)
    end
  end
end

# Add Unicode aware String#upcase and String#downcase methods when mb_chars method is called
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '1.9'
  begin
    gem "unicode_utils", ">=1.0.0"
    require "unicode_utils/upcase"
    require "unicode_utils/downcase"

    module ActiveRecord #:nodoc:
      module ConnectionAdapters #:nodoc:
        module OracleEnhancedUnicodeString #:nodoc:
          def upcase #:nodoc:
            UnicodeUtils.upcase(self)
          end

          def downcase #:nodoc:
            UnicodeUtils.downcase(self)
          end
        end
      end
    end

    class String #:nodoc:
      def mb_chars #:nodoc:
        self.extend(ActiveRecord::ConnectionAdapters::OracleEnhancedUnicodeString)
        self
      end
    end

  rescue LoadError
    warning_message = "WARNING: Please install unicode_utils gem to support Unicode aware upcase and downcase for String#mb_chars"
    if defined?(RAILS_DEFAULT_LOGGER)
      RAILS_DEFAULT_LOGGER.warn warning_message
    else
      STDERR.puts warning_message
    end
  end

  
end

Version data entries

7 entries across 7 versions & 5 rubygems

Version Path
plukevdh-activerecord-oracle_enhanced-adapter-1.2.1 lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb
unclebilly-activerecord-oracle_enhanced-adapter-1.2.4 lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb
c3-activerecord-oracle_enhanced-adapter-1.2.4 lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb
oracle_enhanced-1.2.5 lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb
activerecord-oracle_enhanced-adapter-1.2.4 lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb
activerecord-oracle_enhanced-adapter-1.2.3 lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb
activerecord-oracle_enhanced-adapter-1.2.2 lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb