Module: Refinement::Refine

Defined in:
lib/refine.rb

Instance Method Summary collapse

Instance Method Details

#refine(mod, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/refine.rb', line 14

def refine(mod, &block)
  complain = Refinement.show_warnings
  Refinement.show_warnings = complain == :always
  warn "no #refine, polluting global namespace instead" if complain
  ext = Module.new(&block)
  if mod.respond_to? :prepend, true
    mod.send :prepend, ext
  else
    warn "no #prepend, changing inheritance order" if complain
    mod.send :include, ext
  end
end