ostruct icon indicating copy to clipboard operation
ostruct copied to clipboard

OpenStruct implementation

Results 16 ostruct issues
Sort by recently updated
recently updated
newest added

I am getting the below error when trying to parse a json object into class object. ``` #

Found this while auditing uses of `object_id` in `ruby/ruby`. Pulled out from ruby/ruby#9276. This PR replaces look-ups into an Array by `object_id`s, with an identity Set (see [`Set#compare_by_identity`](https://ruby-doc.org/3.2.2/stdlibs/set/Set.html#method-i-compare_by_identity)). This has...

Hello, I have a case where I overrode respond_to? on a subclass of OpenStruct because I this class to work as fake object. ``` class Dep def a "Hello from...

This modifies the getter definition to use a single method that uses `__callee__` to access the hash. ```ruby def __get_callee__! @table[__callee__] end ``` On versions of Ruby 2.0+ and JRuby...

In the ruby 2 version of OpenStruct, serialized objects can have two root keys: `table` and `modifiable`. The second key only seems to appear after an attribute is assigned post-initialization:...

In at least some cases, the legacy format includes an additional field that needs to be considered. ``` # ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin22] require "ostruct" require "yaml" os...

It would be nice to be able to pattern match against OpenStruct. Inspired by https://github.com/rails/rails/pull/45035 For example: ```ruby person = OpenStruct.new(name: 'John', age: 42) case person in { name: 'John',...

After many hours of head-scratching, I can offer this bug report: ```ruby OpenStruct.new(gem: 'foobar').gem ``` The above code works in "bare" ruby, but not with bundler. Steps to reproduce: ```console...

This PR can enable something like this: ``` person = OpenStruct.new person.name = "John Smith" person.age = 70 person.more_info = {interests: ['singing', 'dancing'], tech_skills: ['Ruby', 'C++']} puts person.more_info.interests puts person.more_info.tech_skills...