On Wed, Aug 19, 2009 at 11:03 PM, Enrico Bianco<[email protected]> wrote:
>
> While trying to debug a process, I noticed that the OpenWFE module
> provides a 'fulldup' method for creating a deep copy of an object. I
> think there's a problem with the implementation. From line 79 of lib/
> openwfe/utils.rb:
>
> o = object.class.new
>
> This won't work for classes that don't have a 0-argument constructor
> (or a constructor in which all arguments have a default value). It
> seems like we should just be cloning the object instead:
>
> o = object.clone
>
> But I'm wondering if this could cause problems in other places.
> Anybody have any further insights here?

Hi Enrico,

yes, there have been troubles in the past, and the current
implementation of OpenWFE.fulldup is the result of an evolution.

If you look at its implementation, you'll notice that at first it
tries to call the target's fulldup method if any, then it tries to use
Marshal (which is quite fast), the it goes on with object.class.new

So usually, object with no zero-args constructors are easily 'cloned'
via Marshal load(dump). (Note that you can customize how the instances
of class get dumped/loaded by provided them with a marshal_load /
marshal_dump method pair)

As a side note, it's not a good idea to try to stuff everything and
the kitchen sink in a workitem. I tend to place in them a minimal
amount of information, mostly references (URIs) to other resources in
the application / enterprise / system.


Hope this help, thanks for using the mailing list and opening the
discussion, cheers,

-- 
John Mettraux   -   http://jmettraux.wordpress.com

--~--~---------~--~----~------------~-------~--~----~
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to