Module: NativeDbTypesOverride

Defined in:
lib/activerecord-native_db_types_override/options.rb,
lib/activerecord-native_db_types_override/version.rb

Constant Summary collapse

VERSION =
'0.1.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.debugObject

Returns the value of attribute debug.



3
4
5
# File 'lib/activerecord-native_db_types_override/options.rb', line 3

def debug
  @debug
end

Class Method Details

.configure(hash) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/activerecord-native_db_types_override/options.rb', line 9

def configure(hash)
  puts "ActiveRecord - Native Database Types Override #{NativeDbTypesOverride::VERSION}" if NativeDbTypesOverride.debug?
  hash.keys.each do |clazz|
    new_types = {}
    begin
      new_types = clazz.const_get('NATIVE_DATABASE_TYPES')
    rescue
      puts "No NATIVE_DATABASE_TYPES constant on #{clazz} so expecting the whole types hash to be specified in the NativeDbTypesOverride::Options.configure" if NativeDbTypesOverride.debug?
    end
    new_types = new_types.merge(hash[clazz])
    puts "Defining #{clazz}.native_database_types as #{new_types.inspect}" if NativeDbTypesOverride.debug?
    clazz.class_eval "def native_database_types; #{new_types.inspect}; end"
  end
end

.debug?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/activerecord-native_db_types_override/options.rb', line 5

def debug?
  !!send(:debug)
end