Module: ActiveRecord::Extensions::SupportMethods

Defined in:
lib/ar-extensions/util/support_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#supports_extension(name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ar-extensions/util/support_methods.rb', line 7

def supports_extension(name)
  class_eval(<<-EOS, __FILE__, __LINE__)
    def self.supports_#{name}?#:nodoc:
      connection.supports_#{name}?
    rescue NoMethodError
     false
    end

    def supports_#{name}?#:nodoc:
      self.class.supports_#{name}?
    end

    def self.supports_#{name}!#:nodoc:
      supports_#{name}? or raise ExtensionNotSupported.new("#{name} extension is not supported. Please require the adapter file.")
    end

    def supports_#{name}!#:nodoc:
      self.class.supports_#{name}!
    end
  EOS
end