VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/lib/gems/2.5.0/gems/eventmachine-le-1.1.7/lib/em/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/lib/gems/2.5.0/gems/eventmachine-le-1.1.7/lib/em/callback.rb
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

VaKeR 2022