Skip to content

Get Defined Properties/Keys #77

Open
@trevorh

Description

@trevorh

Hi,

I just came across your gem as a replacement for Hashie::Mash w/ StrictKeyAccess enabled. I've been having some odd issues that others have had as well.

ROS seems like almost a perfect fit, but I have no way to easily introspect the properties/keys of an object. When I have raise_on_missing: enabled, I really would like to be able check for the presence of a key without resorting to respond_to?.

Specifically, I'm using this with Faraday and am trying out my own middleware based on the Mashify middleware but renamed to Rosify obviously :) . Essentially, it converts any response body to a ROS object when possible.

To get the list of keys I've added a refinement to use when I need it.

  refine RecursiveOpenStruct do
    def _struct_keys
      @table.keys
    end
  end

Is there anything I'm missing or why I shouldn't do something like this?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions