Class: Object

Inherits:
BasicObject
Defined in:
lib/unextendable/object.rb

Instance Method Summary collapse

Instance Method Details

#extend(*modules) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/unextendable/object.rb', line 13

def extend(*modules)
  modules.each do |mod|
    if respond_to?(:meta_class)
      wrap_unextendable_module mod if mod.unextendable?
      add_extended_module mod
    end
    super(mod)
  end
end

#unextend(*modules, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/unextendable/object.rb', line 23

def unextend(*modules, &block)
  if respond_to?(:meta_class)
    if modules.empty?
      meta_class.extended_modules.delete_if do |mod|
        unextend? mod, &block
      end
    else
      modules.each do |mod|
        meta_class.extended_modules.delete mod if unextend? mod, &block
      end
    end
  end
end