Top Level Namespace

Defined Under Namespace

Modules: Transproc

Instance Method Summary collapse

Instance Method Details

#Transproc(fn, *args) ⇒ Function

Access registered functions

Examples:

Transproc(:map_array, Transproc(:to_string))

Transproc(:to_string) >> Transproc(-> v { v.upcase })

Parameters:

  • fn (Symbol, Proc)

    The name of the registered function or an anonymous proc

  • args (Array)

    Optional addition args that a given function may need

Returns:

  • (Function)


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/transproc.rb', line 69

def Transproc(fn, *args)
  Transproc::Deprecations.announce(
    'Transproc()',
    'Define your own function registry using Transproc::Registry extension'
  )

  case fn
  when Proc then Transproc::Function.new(fn, args: args)
  when Symbol
    fun = Transproc[fn, *args]
    case fun
    when Transproc::Function, Transproc::Composite then fun
    else Transproc::Function.new(fun, args: args)
    end
  end
end