Skip to content

Commit

Permalink
Merge pull request #180 from da-ar/to_hash
Browse files Browse the repository at this point in the history
(maint) Add to_hash function to resourceShim for compatibility
  • Loading branch information
DavidS authored Jun 10, 2019
2 parents e7a8184 + be6d8dd commit bda45be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/puppet/resource_api/glue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
4 changes: 4 additions & 0 deletions spec/puppet/resource_api/glue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bda45be

Please sign in to comment.