Sha256: 1ae00eb8fafbdf97ba45a29cd40203975089e87155afd3d5bdffc4f9d66d3137

Contents?: true

Size: 463 Bytes

Versions: 1

Compression:

Stored size: 463 Bytes

Contents

module Added
  def extended(instance)
    super
    added(instance) if respond_to? :added
  end

  def included(klass)
    super
    if respond_to? :added
      mod = self
      klass.prepend(Module.new do
        define_method(:initialize){ |*args, &block|
          super(*args, &block)
          mod.added(self)
        }
      end)
      ObjectSpace.each_object(klass){ |instance|
        added(instance)
      }
    end
  end

  alias prepended included
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
added-1.0.0 lib/added/implementation.rb