Sha256: 60efe15b0c6fd7c17e43d3954f3d718c2c18b008b1c72a8e6d27ead21b0d16e7

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

# -*- coding: utf-8 -*-
require 'uninclude'

class Module
  alias_method :__include, :include
  alias_method :__uninclude, :uninclude

  def include(mod)
    __include(mod)

    if block_given?
      yield(self)
      __uninclude(mod)
    end
  end

  def uninclude(mod)
    return unless ancestors.include?(mod)

    __uninclude(mod)

    if block_given?
      yield(self)
      __include(mod)
    end
  end
end

class Object
  alias_method :__extend, :extend
  alias_method :__unextend, :unextend

  def extend(mod)
    __extend(mod)

    if block_given?
      yield(self)
      __unextend(mod)
    end
  end

  def unextend(mod)
    return unless singleton_class.ancestors.include?(mod)

    __unextend(mod)

    if block_given?
      yield(self)
      __extend(mod)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uninclude-1.3.0 lib/uninclude/block.rb