> On 24 Jul 2017, at 22:29, Peter Meier <peter.me...@immerda.ch> wrote: > >> Now, the reason your call on line 74 >> >> call_function('lookup', key, 'Hash', 'hash',{}) >> >> fails is that you have to pass in a ruby object for the type, not a >> string representation of the type. There's probably a better way that >> would generate an appropriate object based on the string, but this >> works for this case: >> >> call_function('lookup', key, >> Puppet::Pops::Types::PHashType::DEFAULT, 'hash',{}) >> >> That invocation gives the expected error message: >> >> Evaluation Error: Error while evaluating a Function Call, Found >> value has wrong type, expects a Hash value, got String > > Awesome, that works! :) I was navigating within the pops subsystem code > once into this direction, but it felt a bit too clumsy and I didn't > bother to try. > > Thanks for the help! > > I agree that there should be a better (and documented! ;) ) way that > would generate an appropriate object based on the string and if there > isn't there should probably be a user story about it. >
Puppet::Pops::Types::TypeParser#parse can be used to get a data type object given a type expressed as in the puppet language. As an example - this: tparser = Puppet::Pops::Types::TypeParser.singleton t = tparser.parse(‘Array[String]’, scope) would assign a data type of Array type accepting String values to the variable t. An alternative is to use the Puppet::Pops::Types::TypeFactory to create the same Array[String] datatype: tf = Puppet::Pops::Types::TypeFactory t = tf.array_of(tf.string) Hope those help in the future Best, - henrik >> I've filed DOCUMENT-703 to correct the docs. >> https://tickets.puppetlabs.com/browse/DOCUMENT-703 > > Cool, thanks! > > best > > ~pete > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/FDFB80E4-1A5C-44DD-98C1-0D247537E143%40puppet.com. For more options, visit https://groups.google.com/d/optout.