Sha256: 8915ec901daea99ab08d04ef4b2d80110f27b53ab896865d1d64ff5584cedf11

Contents?: true

Size: 430 Bytes

Versions: 1

Compression:

Stored size: 430 Bytes

Contents

module ProxyObject

  def proxy(message, target, target_message=message)
    proxies[message] << [target, target_message]

    file, line = caller.first.split(':')

    instance_eval %{
      def #{message}(*args, &block)
        proxies[:#{message}].each do |target, message|
          target.send(message, *args, &block)
        end
      end
    }, file, line.to_i
  end

  def proxies
    @proxies ||= Hash.new([])
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
proxy-object-1.0.0 lib/proxy_object.rb