Skip to content

Commit bda45be

Browse files
authored
Merge pull request #180 from da-ar/to_hash
(maint) Add to_hash function to resourceShim for compatibility
2 parents e7a8184 + be6d8dd commit bda45be

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/puppet/resource_api/glue.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def to_hierayaml
4141
YAML.dump('type' => { title => attributes }).split("\n").drop(2).join("\n") + "\n"
4242
end
4343

44+
def to_hash
45+
values
46+
end
47+
4448
# attribute names that are not title or namevars
4549
def filtered_keys
4650
values.keys.reject { |k| k == :title || !attr_def[k] || (attr_def[k][:behaviour] == :namevar && @namevars.size == 1) }

spec/puppet/resource_api/glue_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,9 @@
5656
it { expect(instance.to_hierayaml).to eq " ? |-\n foo:\n bar\n : attr: value\n attr_ro: fixed\n" }
5757
end
5858
end
59+
60+
describe '.to_hash' do
61+
it { expect(instance.to_hash).to eq(namevarname: 'title', attr: 'value', attr_ro: 'fixed') }
62+
end
5963
end
6064
end

0 commit comments

Comments
 (0)