module Proc::ValueClassPatch

Public Instance Methods

val(proc_or_object, *args) click to toggle source

Evaluate block if block is given or return unmodified object if no block is given. Additional arguments are given to ‘Proc#call`.

Can be used to allow transparent usage of blocks.

@example

config_option = Proc.val(config_option).to_s

@see Object#value @see Proc#value

# File lib/proc/value.rb, line 15
def val(proc_or_object, *args)
  proc_or_object.respond_to?(:call) ? proc_or_object.call(*args) : proc_or_object
end