kit-contract edge

RubyHelpers module
Kit::Contract::Services::RubyHelpers
View Source

Helpers methods to manipulate function signatures. This should be part of the language in one form or another.


Link to this section Summary ⚠️ Private APIs are currently hidden.


Link to this section Class methods 5

Link to this method

.generate_args_in(callable:, args:)

View Source
🗒 Notes:
  • a valid order looks like: `[:req, :opt], :rest, [:req, :opt], [:key, :keyreq], :keyrest, :block`

Given a callable, attempt to transform args to make it compatible with the signature

Link to this method

.get_parameters(callable:)

View Source

Given a callable, get its parameters data

Link to this method

.handle_key_args(hash:, parameters:)

View Source

Given a hash and some callable parameters, attempts to generate a compatible version of that hash.

Link to this method

.parameters_as_array_to_s(parameters:)

View Source
🗒 Notes:
  • This is a poor man Ruby equivalent of javascript `arguments`

Given some callable parameters, attempt to generate the array we would have gotten when using a single splat.

Link to this method

.parameters_as_signature_to_s(parameters:)

View Source
🗒 Notes:
  • Default values are not available, so they are lost. Kudos to Ruby.

Given some callable parameters, generate the a callable definition