Module: Tripod::Extensions::Module

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

Instance Method Summary collapse

Instance Method Details

#re_define_method(name, &block) ⇒ Method

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

Parameters:

  • name (String, Symbol)

    The name of the method.

  • block (Proc)

    The method body.

Returns:

  • (Method)

    The new method.



17
18
19
20
# File 'lib/tripod/extensions/module.rb', line 17

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