Module: Mixology

Defined in:
lib/mixology_rubinius.rb,
ext/mixology/mixology.c

Instance Method Summary collapse

Instance Method Details

#mixin(module) ⇒ Object



95
96
97
98
99
100
101
# File 'ext/mixology/mixology.c', line 95

def mixin(mod)
  unmix mod
  reset_method_cache
  IncludedModule.new(mod).attach_to metaclass
  reset_method_cache
  self
end

#unmix(module) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'ext/mixology/mixology.c', line 39

def unmix(mod_to_unmix)
  last_super = metaclass
  this_super = metaclass.direct_superclass
  while this_super
    break if this_super == self.class
    if (this_super == mod_to_unmix ||
        this_super.respond_to?(:module) && this_super.module == mod_to_unmix)
      reset_method_cache
      last_super.superclass = this_super.direct_superclass
      reset_method_cache
      return self
    else
      last_super = this_super
      this_super = this_super.direct_superclass
    end
  end
  self
end