Sha256: d011258e43794513f9f3f25b57edbe018d67f21abe939a37a91bcc4c7da911f7
Contents?: true
Size: 843 Bytes
Versions: 236
Compression:
Stored size: 843 Bytes
Contents
module Eco module Language def required_parameters(method) method.parameters.select { |type, _| type == :req || :keyreq} end def required_parameters?(method) required_parameters(method).length > 0 end def curry(method) -> (*args, **kargs) { required = method.parameters.select { |type, _| type == :req } krequired = method.parameters.select { |type, _| type == :keyreq } all_args = (required.length <= args.length) all_keys = krequired.all? { |_, name| kargs.has_key?(name) } if all_args && all_keys final_args = (args + kargs.map {|k,v| {k => v} }) method.call(*final_args) else -> (*args_, **kargs_) { curry(method)[*args, *args_, **kargs, **kargs_] } end } end end end
Version data entries
236 entries across 236 versions & 1 rubygems