Method: Transproc::Conditional.is

Defined in:
lib/transproc/conditional.rb

.is(value, type, fn) ⇒ Object

Calls a function when type-check passes

Examples:

fn = Transproc(:is, Array, -> arr { arr.map(&:upcase) })
fn.call(['a', 'b', 'c']) # => ['A', 'B', 'C']

fn = Transproc(:is, Array, -> arr { arr.map(&:upcase) })
fn.call('foo') # => "foo"

Parameters:

  • (Object)
  • (Class)
  • (Proc)

Returns:

  • (Object)


68
69
70
# File 'lib/transproc/conditional.rb', line 68

def self.is(value, type, fn)
  guard(value, -> v { v.is_a?(type) }, fn)
end