Puppet::ResourceApi::ResourceShim should respond to to_hash in a manner equivalent to the way Puppet::Resource does, so that code that calls this method on normal resource objects can also function with resources from the Resource API.
The primary example I know off the top of my head is crayfishx's purge module, which provides an improved version of the core resources type for purging unmanaged resources. In his module, he calls .to_resource to get Puppet::Resource objects, and then calls .to_hash on them to get their attributes hash. However, the Puppet Resource API overrides to_resource so that it returns a Puppet::ResourceApi::ResourceShim object instead of a Puppet::Resource object, and ResourceShim doesn't implement to_hash like Resource does.
I believe a reasonable implementation that matched the semantics of Puppet::Resource would simply be
def to_hash
values.dup
end
Puppet::ResourceApi::ResourceShimshould respond toto_hashin a manner equivalent to the wayPuppet::Resourcedoes, so that code that calls this method on normal resource objects can also function with resources from the Resource API.The primary example I know off the top of my head is crayfishx's purge module, which provides an improved version of the core
resourcestype for purging unmanaged resources. In his module, he calls.to_resourceto getPuppet::Resourceobjects, and then calls.to_hashon them to get their attributes hash. However, the Puppet Resource API overridesto_resourceso that it returns aPuppet::ResourceApi::ResourceShimobject instead of aPuppet::Resourceobject, andResourceShimdoesn't implementto_hashlikeResourcedoes.I believe a reasonable implementation that matched the semantics of
Puppet::Resourcewould simply be