M
Mark Volkmann
The way to determine the names of the attributes of objects created
from a Class, Struct and OpenStruct are all different.
For an object created from a Class you call "instance_variables". I
wish that method would have been named "attributes".
For an object created from a Struct you call "members". Why not the
same as the previous case?
For an object created using OpenStruct you call "marshal_dump.keys".
My first guess was to call "table.keys", but the table attribute is
protected.
I think there should be a common way to do this for all three cases.
Suggestion #1
- add an "instance_variables" method to Struct that is the same as "members=
"
- add an "instance_variables" method to OpenStruct that returns @table.keys
Suggestion #2
- add an "attributes" method to Class that is the same as "instance_variabl=
es"
- add an "attributes" method to Struct that is the same as "members"
- add an "attributes" method to OpenStruct that returns @table.keys
--=20
R. Mark Volkmann
Partner, Object Computing, Inc.
from a Class, Struct and OpenStruct are all different.
For an object created from a Class you call "instance_variables". I
wish that method would have been named "attributes".
For an object created from a Struct you call "members". Why not the
same as the previous case?
For an object created using OpenStruct you call "marshal_dump.keys".
My first guess was to call "table.keys", but the table attribute is
protected.
I think there should be a common way to do this for all three cases.
Suggestion #1
- add an "instance_variables" method to Struct that is the same as "members=
"
- add an "instance_variables" method to OpenStruct that returns @table.keys
Suggestion #2
- add an "attributes" method to Class that is the same as "instance_variabl=
es"
- add an "attributes" method to Struct that is the same as "members"
- add an "attributes" method to OpenStruct that returns @table.keys
--=20
R. Mark Volkmann
Partner, Object Computing, Inc.