module ResourceStruct
includes the factory method ResourceStruct.new(hash, opts) for building the various types of structs provided by the library.
Constants
- FirmStruct
StrictStruct
provides a struct by which accessing undefined fields raises a MethodMissing error. This protects against accessing fields that are not present in API Responses.If you need to check whether a field exists in an api response, you can via name? methods.
struct =
StrictStruct.new
({ “foo” => 1, “bar” => [{ “baz” => 2 }, 3] })struct.foo? # => true struct.brr? # => false struct.foo # => 1 struct.bar # => [StrictStruct<{ “baz” => 2 }>, 3] struct.brr # => NoMethodError struct # => 1 struct # => nil struct[:bar, 0, :baz] # => 2 struct[:bar, 0, :brr] # => nil
- LooseStruct
FlexStruct
provides a struct by which accessing undefined fields returns nilstruct =
FlexStruct.new
({ “foo” => 1, “bar” => [{ “baz” => 2 }, 3] })struct.foo? # => true struct.brr? # => false struct.foo # => 1 struct.bar # => [FlexStruct<{ “baz” => 2 }>, 3] struct.brr # => nil struct # => 1 struct # => nil struct[:bar, 0, :baz] # => 2 struct[:bar, 0, :brr] # => nil
- VERSION