@@ -111,6 +111,13 @@ def from_h!(value)
111111 self . length = value [ 'length' ]
112112 self
113113 end
114+
115+ private
116+
117+ def value_from_hash ( hash , key )
118+ # The key could be a Symbol or String in the hash
119+ hash [ key ] . nil? ? hash [ key . to_s ] : hash [ key ]
120+ end
114121 end
115122
116123 class BasePuppetObjectList < Array
@@ -173,9 +180,10 @@ def from_h!(value)
173180 self . parameters = { }
174181 unless value [ 'parameters' ] . nil?
175182 value [ 'parameters' ] . each do |attr_name , obj_attr |
183+ # TODO: This should be a class, not a hash
176184 parameters [ attr_name ] = {
177- :type => obj_attr [ ' type' ] ,
178- :doc => obj_attr [ ' doc' ]
185+ :type => value_from_hash ( obj_attr , : type) ,
186+ :doc => value_from_hash ( obj_attr , : doc)
179187 }
180188 end
181189 end
@@ -204,7 +212,7 @@ def to_h
204212 super . to_h . merge (
205213 'doc' => doc ,
206214 'function_version' => function_version ,
207- 'signatures' => signatures
215+ 'signatures' => signatures . map ( & :to_h )
208216 )
209217 end
210218
@@ -240,7 +248,7 @@ def to_h
240248 'key' => key ,
241249 'doc' => doc ,
242250 'return_types' => return_types ,
243- 'parameters' => parameters
251+ 'parameters' => parameters . map ( & :to_h )
244252 }
245253 end
246254
@@ -311,10 +319,11 @@ def from_h!(value)
311319 unless value [ 'attributes' ] . nil?
312320 value [ 'attributes' ] . each do |attr_name , obj_attr |
313321 attributes [ attr_name . intern ] = {
314- :type => obj_attr [ 'type' ] . intern ,
315- :doc => obj_attr [ 'doc' ] ,
316- :required? => obj_attr [ 'required?' ] ,
317- :isnamevar? => obj_attr [ 'isnamevar?' ]
322+ # TODO: This should be a class, not a hash
323+ :type => value_from_hash ( obj_attr , :type ) . intern ,
324+ :doc => value_from_hash ( obj_attr , :doc ) ,
325+ :required? => value_from_hash ( obj_attr , :required? ) ,
326+ :isnamevar? => value_from_hash ( obj_attr , :isnamevar? )
318327 }
319328 end
320329 end
0 commit comments