Method: Module#preextend

Defined in:
lib/core/facets/module/preextend.rb

#preextend(aspect) ⇒ Object

Prepend an aspect module to a module. This only works at the module level.

module ::PreX
  def x; "x"; end
end

module ::PreU
  def x; '{' + super + '}'; end
end

PreX.preextend(PreU)

PreX.x  # => "{x}"

NOTE: This is not a common core extension and is not loaded automatically when using require 'facets'.

CREDIT Trans

Uncommon:

  • require ‘facets/module/preextend’



26
27
28
29
# File 'lib/core/facets/module/preextend.rb', line 26

def preextend(aspect)
  aspect.__send__(:include, self)
  extend aspect
end