Module: Mongoid::Extensions::Module

Defined in:
lib/mongoid/extensions/module.rb

Instance Method Summary (collapse)

Instance Method Details

- (Method) re_define_method(name, &block)

Redefine the method. Will undef the method if it exists or simply just define it.

Examples:

Redefine the method.

Object.re_define_method("exists?") do
  self
end

Since:

  • 3.0.0



20
21
22
23
# File 'lib/mongoid/extensions/module.rb', line 20

def re_define_method(name, &block)
  undef_method(name) if method_defined?(name)
  define_method(name, &block)
end