Sha256: a414a7f9eb499ba780218d46642241e526dead9db721dcab796586688a6eb267

Contents?: true

Size: 466 Bytes

Versions: 2

Compression:

Stored size: 466 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.send(:prepend, Module.new{
        define_method(:initialize){ |*args, &block|
          super(*args, &block)
          mod.added(self)
        }
      })
      ObjectSpace.each_object(klass){ |instance|
        added(instance)
      }
    end
  end

  alias prepended included
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
added-1.0.2 lib/added/implementation.rb
added-1.0.1 lib/added/implementation.rb