diff --git a/lib/puppet/resource_api/glue.rb b/lib/puppet/resource_api/glue.rb index 85628c3e..8eee448d 100644 --- a/lib/puppet/resource_api/glue.rb +++ b/lib/puppet/resource_api/glue.rb @@ -41,6 +41,10 @@ def to_hierayaml YAML.dump('type' => { title => attributes }).split("\n").drop(2).join("\n") + "\n" end + def to_hash + values + end + # attribute names that are not title or namevars def filtered_keys values.keys.reject { |k| k == :title || !attr_def[k] || (attr_def[k][:behaviour] == :namevar && @namevars.size == 1) } diff --git a/spec/puppet/resource_api/glue_spec.rb b/spec/puppet/resource_api/glue_spec.rb index 2a1ee68d..c31b8c00 100644 --- a/spec/puppet/resource_api/glue_spec.rb +++ b/spec/puppet/resource_api/glue_spec.rb @@ -56,5 +56,9 @@ it { expect(instance.to_hierayaml).to eq " ? |-\n foo:\n bar\n : attr: value\n attr_ro: fixed\n" } end end + + describe '.to_hash' do + it { expect(instance.to_hash).to eq(namevarname: 'title', attr: 'value', attr_ro: 'fixed') } + end end end