lib/garcon/chef/chef_helpers.rb
# Invokes the public method whose name goes as first argument just like
# `public_send` does, except that if the receiver does not respond to
# it the call returns `nil` rather than raising an exception.
#
# @note `_?` is defined on `Object`. Therefore, it won't work with
# instances of classes that do not have `Object` among their ancestors,
# like direct subclasses of `BasicObject`.
#
# @param [String] object
#   The object to send the method to.
#
# @param [Symbol] method
#   The method to send to the object.
#
# @api public
Invokes the public method whose name goes as first argument just like
`public_send` does, except that if the receiver does not respond to
it the call returns `nil` rather than raising an exception.
Invokes the public method whose name goes as first argument just like ` public_send ` does except that if the receiver does not respond to it the call returns ` nil ` rather than raising an exception .
def _?(*args, &block)
      if args.empty? && block_given?
        yield self
      else
        resp = public_send(*args[0], &block) if respond_to?(args.first)
        return nil if resp.nil?
        !!resp == resp ? args[1] : [args[1], resp]
      end
    end
def _? ( * args , & block ) if args . empty? && block_given? yield self else resp = public_send ( * args [ 0 ] , & block ) if respond_to? ( args . first ) return nil if resp . nil? ! ! resp == resp ? args [ 1 ] : [ args [ 1 ] , resp ] end end
Invokes the public method whose name goes as first argument just like
`public_send` does, except that if the receiver does not respond to
it the call returns `nil` rather than raising an exception.
Invokes the public method whose name goes as first argument just like ` public_send ` does except that if the receiver does not respond to it the call returns ` nil ` rather than raising an exception .
args
<not_specific>
block
<not_specific>
<not_specific>
method The method to send to the object.
method The method to send to the object .
note
`_?` is defined on `Object`. Therefore, it won't work with instances of classes that do not have `Object` among their ancestors, like direct subclasses of `BasicObject`.
` _? ` is defined on ` Object ` . Therefore it won ' t work with instances of classes that do not have ` Object ` among their ancestors like direct subclasses of ` BasicObject ` .
api
None