Module: DataMapper::Constraints::Adapters::Extension

Included in:
DataMapper
Defined in:
lib/data_mapper/constraints/adapters/extension.rb

Instance Method Summary collapse

Instance Method Details

#include_constraint_api(const_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Include the corresponding Constraints module into a adapter class

TODO: come up with a better way to include modules into all currently loaded and subsequently loaded Adapters

Parameters:

  • const_name (Symbol)

    demodulized name of the adapter class to include corresponding constraints module into


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/data_mapper/constraints/adapters/extension.rb', line 15

def include_constraint_api(const_name)
  require constraint_extensions(const_name)

  if Constraints::Adapters.const_defined?(const_name)
    adapter = const_get(const_name)
    constraint_module = Constraints::Adapters.const_get(const_name)
    adapter.class_eval { include constraint_module }
  end
rescue LoadError
  # Silently ignore the fact that no adapter extensions could be required
  # This means that the adapter in use doesn't support constraints
end