Sha256: 24cee17e07f9ec75b30242c701cce23eb1003ca07328c3e6b0b12ba7972bc124
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module Phlex class Unbuffered < BasicObject def initialize(object) @object = object end def inspect "Unbuffered(#{@object.class.name})[object: #{@object.inspect}]" end # Borrow some important methods from Object define_method :__class__, ::Object.instance_method(:class) define_method :__public_send__, ::Object.instance_method(:public_send) def respond_to_missing?(...) @object.respond_to?(...) end def method_missing(name, *args, **kwargs, &block) if @object.respond_to?(name) __class__.define_method(name) do |*a, **k, &b| @object.capture { @object.public_send(name, *a, **k, &b) } end # Now we've defined this missing method, we can call it. __public_send__(name, *args, **kwargs, &block) else super end end # Forward some methods to the original underlying method def call(...) @object.call(...) end def send(...) @object.send(...) end def public_send(...) @object.public_send(...) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
phlex-1.3.3 | lib/phlex/unbuffered.rb |
phlex-1.3.2 | lib/phlex/unbuffered.rb |
phlex-1.3.1 | lib/phlex/unbuffered.rb |