HomePhorge

(PUP-3978) Pass block using Ruby semantics, not as normal parameter
07db7cf6d0d9Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(PUP-3978) Pass block using Ruby semantics, not as normal parameter

Passing a block as a normal parameter messed up the notion of
optional parameters since the last parameter could be a required
block. It also made the calling convention somewhat unorthodox
from a ruby developers point of view.

This commit introduces a new class 'PuppetProc' derived from the Ruby
'Proc'. It wrapps the normal closure that would otherwise be passed in
a parameter and enables it to instead be passed as a block, thus
making it possible to use standard calls like 'block_given?' and
'yield' to execute a Puppet lambda from Ruby.

The 'TypeCalculator' will infer a 'PuppetProc' to the type of its
closure. It is also capable of inferring a normal ruby 'Proc' using the
information returned by its 'parameters' method so that all parameters
are of type 'Any' and the min/max is controlled by the :req, :opt, and
:rest indicators of the parameter info arrays.

Details

Provenance
Thomas Hallgren <thomas@tada.se>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU856c7ced2a10: Merge pull request #3588 from thallgren/issue/pup-3274/no-scope-param
Branches
Unknown
Tags
Unknown

Event Timeline

Thomas Hallgren <thomas@tada.se> committed rPU07db7cf6d0d9: (PUP-3978) Pass block using Ruby semantics, not as normal parameter (authored by Thomas Hallgren <thomas@tada.se>).Feb 10 2015, 9:39 AM