class PipeOperator::Proxy
Public Class Methods
new(object, singleton)
click to toggle source
Calls superclass method
# File lib/pipe_operator/proxy.rb 3 def initialize(object, singleton) 4 @object = object if singleton.singleton_class? 5 @singleton = singleton 6 super() 7 end
Public Instance Methods
define(method)
click to toggle source
Calls superclass method
# File lib/pipe_operator/proxy.rb 9 def define(method) 10 if ::Proc == @object && method == :new 11 return method 12 elsif ::Symbol == @singleton && method == :to_proc 13 return method 14 elsif ::Module === @object 15 namespace = @object.name.to_s.split("::").first 16 return method if namespace == "PipeOperator" 17 end 18 19 define_method(method) do |*args, &block| 20 if Pipe.open 21 Pipe.new(self).__send__(method, *args, &block) 22 else 23 super(*args, &block) 24 end 25 end 26 end
definitions()
click to toggle source
# File lib/pipe_operator/proxy.rb 28 def definitions 29 instance_methods(false).sort 30 end
inspect()
click to toggle source
# File lib/pipe_operator/proxy.rb 32 def inspect 33 inspect = 34 if @singleton.singleton_class? 35 ::PipeOperator.inspect(@object) 36 else 37 "#<#{@singleton.name}>" 38 end 39 40 "#<#{self.class.name}:#{inspect}>" 41 end
prepended(*)
click to toggle source
Calls superclass method
# File lib/pipe_operator/proxy.rb 43 def prepended(*) 44 if is_a?(Proxy) 45 methods = @singleton.instance_methods(false) 46 methods.each { |method| define(method) } 47 end 48 49 super 50 end
undefine(method)
click to toggle source
# File lib/pipe_operator/proxy.rb 52 def undefine(method) 53 remove_method(method) 54 rescue ::NameError # ignore 55 method 56 end