Skip to content

ResourceShim should respond to to_hash #179

Closed
@philomory

Description

@philomory

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions