From: Peter Vandenabeele Date: 2012-02-14T00:28:56+09:00 Subject: [ruby-core:42554] Re: [ruby-trunk - Feature #1400] Please add a method to enumerate fields in OpenStruct --00235429d75cdd877d04b8da22db Content-Type: text/plain; charset=UTF-8 On Mon, Feb 13, 2012 at 4:08 PM, Yusuke Endoh wrote: > > Issue #1400 has been updated by Yusuke Endoh. > > Assignee changed from Yukihiro Matsumoto to Marc-Andre Lafortune > > Hello, > > There is no maintainer for ostruct. > Marc-Andre, are you willing to be a maintainer and to commit > your patch? I give +1 for __members__. > > I consider Dan's comment is not objection. What Tomas wants is > a way to get field names without depending on the openstruct > internal. But the ways that Dan proposed are deeply depending > on it. For other topics, please register bug ticket for each. > I use OpenStruct#marshal_dump for this purpose, which is a public method and returns a clean hash. $ irb 1.9.3p0 :001 > require 'ostruct' => false 1.9.3p0 :002 > car = OpenStruct.new => # 1.9.3p0 :003 > car.wheels = 4 => 4 1.9.3p0 :004 > car.seats = 5 => 5 1.9.3p0 :005 > car.marshal_dump => {:wheels=>4, :seats=>5} Sincerely, Peter -- *** Available for a new project *** Peter Vandenabeele http://twitter.com/peter_v http://rails.vandenabeele.com http://coderwall.com/peter_v --00235429d75cdd877d04b8da22db Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Mon, Feb 13, 2012 at 4:08 PM, Yusuke Endoh <mame@tsg.ne.jp>= ; wrote:

Issue #1400 has been updated by Yusuke Endoh.

Assignee changed from Yukihiro Matsumoto to Marc-Andre Lafortune

Hello,

There is no maintainer for ostruct.
Marc-Andre, are you willing to be a maintainer and to commit
your patch? =C2=A0I give +1 for __members__.

I consider Dan's comment is not objection. =C2=A0What Tomas wants is a way to get field names without depending on the openstruct
internal. =C2=A0But the ways that Dan proposed are deeply depending
on it. =C2=A0For other topics, please register bug ticket for each.

I use OpenStruct#marshal_dump for this purpose,
which = is a public method and returns a clean hash.

$ irb
1.9.3p0 :001 &= gt; require 'ostruct'
=C2=A0=3D> false
1.9.3p0 :002 > car =3D OpenStruct.new
=C2=A0= =3D> #<OpenStruct>
1.9.3p0 :003 > car.wheels =3D 4
=C2= =A0=3D> 4
1.9.3p0 :004 > car.seats =3D 5
=C2=A0=3D> 5
1= .9.3p0 :005 > car.marshal_dump
=C2=A0=3D> {:wheels=3D>4, :seats=3D>5}

Sincerely,

P= eter


--
*** Available for a new pr= oject ***

Peter Vandenabeele
http://twitter.com= /peter_v
http://rails.vandenabeele.com
http://coderwall.com/peter_v
--00235429d75cdd877d04b8da22db--