The simple case, is this guy:
> m = SecureRandom.method(:hex)
=> #<Method: SecureRandom.hex>
> m.call
=> "5928aab178404945fb560a249b67a000"
> m.call
=> "d5ba69ac2e9dc8632aee7bf3212f6d67"
But, what I want, is a fully curried function. Something like this:
> m = SecureRandom.method(:hex, 6)
=> #<Method: SecureRandom.hex>
> m.call
=> "bd131d38de3c"
> m.call
=> "4e5a20936be0"
But Object#method
doesn't take more than one argument. So, to get the effect I want, I have to do something like this:
> m = -> { SecureRandom.hex(6) }
=> #<Proc:0x000000034144b8@(pry):7 (lambda)>
> m.call
=> "bd131d38de3c"
> m.call
=> "4e5a20936be0"
It's not a huge thing, just a little sugar, but still.
So @avdi pointed out Proc#curry. And I tried it out, but it's a bit weird about arity:
Basically, as soon as the arity of the curried function is met, it evaluates it down, so you can't fill the args all up and then wait to call it... without explicitly making a lambda.