From 5571dc766e2143e39762ff0b47c41d1c2e154f4c Mon Sep 17 00:00:00 2001 From: Benjamin Sanders Date: Sat, 11 Oct 2025 10:34:24 -0400 Subject: Vendor bundled gems for deployment --- .../gems/eventmachine-1.2.7/lib/em/callback.rb | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 vendor/bundle/ruby/3.4.0/gems/eventmachine-1.2.7/lib/em/callback.rb (limited to 'vendor/bundle/ruby/3.4.0/gems/eventmachine-1.2.7/lib/em/callback.rb') diff --git a/vendor/bundle/ruby/3.4.0/gems/eventmachine-1.2.7/lib/em/callback.rb b/vendor/bundle/ruby/3.4.0/gems/eventmachine-1.2.7/lib/em/callback.rb new file mode 100644 index 0000000..4928feb --- /dev/null +++ b/vendor/bundle/ruby/3.4.0/gems/eventmachine-1.2.7/lib/em/callback.rb @@ -0,0 +1,58 @@ +module EventMachine + # Utility method for coercing arguments to an object that responds to :call. + # Accepts an object and a method name to send to, or a block, or an object + # that responds to :call. + # + # @example EventMachine.Callback used with a block. Returns that block. + # + # cb = EventMachine.Callback do |msg| + # puts(msg) + # end + # # returned object is a callable + # cb.call('hello world') + # + # + # @example EventMachine.Callback used with an object (to be more specific, class object) and a method name, returns an object that responds to #call + # + # cb = EventMachine.Callback(Object, :puts) + # # returned object is a callable that delegates to Kernel#puts (in this case Object.puts) + # cb.call('hello world') + # + # + # @example EventMachine.Callback used with an object that responds to #call. Returns the argument. + # + # cb = EventMachine.Callback(proc{ |msg| puts(msg) }) + # # returned object is a callable + # cb.call('hello world') + # + # + # @overload Callback(object, method) + # Wraps `method` invocation on `object` into an object that responds to #call that proxies all the arguments to that method + # @param [Object] Object to invoke method on + # @param [Symbol] Method name + # @return [<#call>] An object that responds to #call that takes any number of arguments and invokes method on object with those arguments + # + # @overload Callback(object) + # Returns callable object as is, without any coercion + # @param [<#call>] An object that responds to #call + # @return [<#call>] Its argument + # + # @overload Callback(&block) + # Returns block passed to it without any coercion + # @return [<#call>] Block passed to this method + # + # @raise [ArgumentError] When argument doesn't respond to #call, method name is missing or when invoked without arguments and block isn't given + # + # @return [<#call>] + def self.Callback(object = nil, method = nil, &blk) + if object && method + lambda { |*args| object.__send__ method, *args } + else + if object.respond_to? :call + object + else + blk || raise(ArgumentError) + end # if + end # if + end # self.Callback +end # EventMachine -- cgit v1.2.3