Sha256: 96cc505447444312e50098a29cf147c5a395b5aa539702fa7ef956dbcb9b08a7

Contents?: true

Size: 464 Bytes

Versions: 1

Compression:

Stored size: 464 Bytes

Contents

class Object
  # Like #respond_to, but return the result of the call if it does.
  # This is a perfect example of where NackClass can be useful --
  # if NackClass exists, an instance of it will be returned if
  # the method is not found, otherwise <tt>nil</tt> is used.
  #
  #   require 'facet/object/respond_with_value'
  #
  #
  def respond_with_value(sym, *args)
    return (defined?(Nack) ? nack : nil) if not respond_to?(sym, *args)
    send(sym)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-0.6.3 lib/facet-dev/object/respond_with_value.rb