Afficher un message
Vieux 13/03/2008, 13h26   #7
Arlen Cuss
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Get OpenStruct attributes

[Note: parts of this message were removed to make it a legal post.]

Hi,

On Thu, Mar 13, 2008 at 7:04 AM, Trans <transfire@gmail.com> wrote:

> o = OpenStruct.new(:a=>1,:b=>2)
> => #<OpenStruct a=1, b=2>
> >> o.instance_variable_get("@table")

> => {:a=>1, :b=>2}
>


Looking into internals sounds dangerous. How about -

>> a = OpenStruct.new

=> #<OpenStruct>
>> a.field = "this"

=> "this"
>> a.old = "that"

=> "that"
>> a.methods false

=> ["field=", "old=", "field", "old"]
>>


Arlen

  Réponse avec citation
 
Page generated in 0,04515 seconds with 9 queries