Issue #6056 has been updated by Marc-Andre Lafortune.

Assignee set to Marc-Andre Lafortune
Target version set to 2.0.0

Hi.

In the future, please break requests in independent parts.

- new_ostruct_member will be protected

- `==` is already defined. I don't think any coercion can be accepted in this case. You can't compare a Set and an Array directly, for instance. Open a new request if you disagree and show use case and how that would be consistent with other builtin and library classes.

- `eql?` has already an issue opened: https://bugs.ruby-lang.org/issues/6029 . Please comment there if need be.

- `each_pair` and `to_h` is the subject of https://bugs.ruby-lang.org/issues/1400 . Please comment there if need be.

- `marshal_dump` is not meant for public use, no `dup` needed. I will remove the explicit documentation once issue 1400 is closed, as one should probably not rely on its implementation.

- "making OpenStruct a subclass of BasicObject". I don't see why and can see different problem with it.  Please make a separate request for it with justification (e.g. why should it would be more helpful if it did not implement `respond_to?`, `send`, `object_id`, etc...) if you want this.

This leaves "Access via [] and []=", which we can discuss in this thread. I was wondering about this myself, about why it wasn't implemented like this to start with. I'm inclined to think it would be a good idea.
----------------------------------------
Feature #6056: Enhancements to OpenStruct
https://bugs.ruby-lang.org/issues/6056

Author: Thomas Sawyer
Status: Open
Priority: Normal
Assignee: Marc-Andre Lafortune
Category: lib
Target version: 2.0.0


This patch fixes one issue, protecting #new_ostruct_member method, and possibly another by dup'ing marshal_dump, but I need more feedback on the later b/c I've also been told it is not needed.

The rest of this patch provides enhancements to OpenStruct that I feel are sorely needed, these include access via [] and []=, ability to mass update via merge!, minimal polymorphism with Hash and the addition of equality methods, eql? and ==.

https://github.com/ruby/ruby/pull/95

I'd also like opinions on further enhancements:

* adding #each and #each_pair
* making OpenStruct a subclass of BasicObject



-- 
http://bugs.ruby-lang.org/