Module: NativeDbTypesOverride

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

Defined Under Namespace

Classes: AdapterOverrider, ConfigurationError

Constant Summary collapse

VERSION =
'0.3.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.adapters_optionsObject

Returns the value of attribute adapters_options.



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

def adapters_options
  @adapters_options
end

.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

.migrations_optionsObject

Returns the value of attribute migrations_options.



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

def migrations_options
  @migrations_options
end

Class Method Details

.configure(hash) ⇒ Object



9
10
11
12
# File 'lib/activerecord-native_db_types_override/options.rb', line 9

def configure(hash)
  warn 'NativeDbTypesOverride.configure is deprecated! Call NativeDbTypesOverride.adapters instead of NativeDbTypesOverride.configure.'
  configure_adapters(hash)
end

.configure_adapters(hash) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/activerecord-native_db_types_override/options.rb', line 14

def configure_adapters(hash)
  puts "ActiveRecord - Native Database Types Override #{NativeDbTypesOverride::VERSION} - configure_adapters called" if NativeDbTypesOverride.debug?
  hash.keys.each do |key|
    begin
      clazz = ::NativeDbTypesOverride::AdapterOverrider.convert_symbol_to_class(key)
    rescue => e
      raise ::NativeDbTypesOverride::ConfigurationError.new "Unable to get adapter class for #{key.inspect}. Try specifying the adapter class itself as the key in the hash in NativeDbTypesOverride.configure(). Error: #{e.message}\n#{e.backtrace.join("\n")}"
    end

    ::NativeDbTypesOverride::AdapterOverrider.override_native_database_types(clazz, hash[key])
  end
end

.configure_migrations(hash) ⇒ Object



27
28
29
30
# File 'lib/activerecord-native_db_types_override/options.rb', line 27

def configure_migrations(hash)
  puts "ActiveRecord - Native Database Types Override #{NativeDbTypesOverride::VERSION} - configure_adapters called" if NativeDbTypesOverride.debug?
  self.migrations_options = hash
end

.debug?Boolean

Returns:

  • (Boolean)


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

def debug?
  !!send(:debug)
end