[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

marshal_load, marshal_dump

Tim Hunter

12/13/2008 10:36:00 PM

Currently RMagick uses the old _dump and _load methods to
marshal/unmarshal images. I'd like to start using the new marshal_load
and marshal_dump methods. What is the impact of switching? Can I just
replace _dump and _load with marshal_dump and marshal_load? Suppose I
have an image that was dumped using an old version of RMagick. How do I
support loading it?

--
RMagick: http://rmagick.ruby...

5 Answers

Eric Hodel

12/15/2008 11:06:00 PM

0

On Dec 13, 2008, at 14:36 PM, Tim Hunter wrote:
> Currently RMagick uses the old _dump and _load methods to marshal/
> unmarshal images. I'd like to start using the new marshal_load and
> marshal_dump methods. What is the impact of switching? Can I just
> replace _dump and _load with marshal_dump and marshal_load? Suppose
> I have an image that was dumped using an old version of RMagick. How
> do I support loading it?

Note that _dump/_load occurs before allocate and marshal_dump/
marshal_load occurs after. In some instances this is an important
distinction.

Tim Hunter

12/16/2008 1:20:00 AM

0

Eric Hodel wrote:
> On Dec 13, 2008, at 14:36 PM, Tim Hunter wrote:
>> Currently RMagick uses the old _dump and _load methods to
>> marshal/unmarshal images. I'd like to start using the new marshal_load
>> and marshal_dump methods. What is the impact of switching? Can I just
>> replace _dump and _load with marshal_dump and marshal_load? Suppose I
>> have an image that was dumped using an old version of RMagick. How do
>> I support loading it?
>
> Note that _dump/_load occurs before allocate and
> marshal_dump/marshal_load occurs after. In some instances this is an
> important distinction.
>
>

Absolutely. I wish I could find some examples of custom
marshal_dump/marshal_load implementations. Searching thru the
1.8.7/1.9.1 sources didn't turn up anything illuminating.

--
RMagick: http://rmagick.ruby...

Eric Hodel

12/16/2008 6:23:00 AM

0

On Dec 15, 2008, at 17:20 PM, Tim Hunter wrote:
> Eric Hodel wrote:
>> On Dec 13, 2008, at 14:36 PM, Tim Hunter wrote:
>>> Currently RMagick uses the old _dump and _load methods to marshal/
>>> unmarshal images. I'd like to start using the new marshal_load and
>>> marshal_dump methods. What is the impact of switching? Can I just
>>> replace _dump and _load with marshal_dump and marshal_load?
>>> Suppose I have an image that was dumped using an old version of
>>> RMagick. How do I support loading it?
>> Note that _dump/_load occurs before allocate and marshal_dump/
>> marshal_load occurs after. In some instances this is an important
>> distinction.
>
> Absolutely. I wish I could find some examples of custom marshal_dump/
> marshal_load implementations. Searching thru the 1.8.7/1.9.1 sources
> didn't turn up anything illuminating.

Look in RubyGems. Gem::Specification, Gem::Version and
Gem::Requirement have custom marshal methods.

Tim Hunter

12/16/2008 12:14:00 PM

0

Eric Hodel wrote:
> On Dec 15, 2008, at 17:20 PM, Tim Hunter wrote:
>> Eric Hodel wrote:
>>> On Dec 13, 2008, at 14:36 PM, Tim Hunter wrote:
>>>> Currently RMagick uses the old _dump and _load methods to
>>>> marshal/unmarshal images. I'd like to start using the new
>>>> marshal_load and marshal_dump methods. What is the impact of
>>>> switching? Can I just replace _dump and _load with marshal_dump and
>>>> marshal_load? Suppose I have an image that was dumped using an old
>>>> version of RMagick. How do I support loading it?
>>> Note that _dump/_load occurs before allocate and
>>> marshal_dump/marshal_load occurs after. In some instances this is an
>>> important distinction.
>>
>> Absolutely. I wish I could find some examples of custom
>> marshal_dump/marshal_load implementations. Searching thru the
>> 1.8.7/1.9.1 sources didn't turn up anything illuminating.
>
> Look in RubyGems. Gem::Specification, Gem::Version and Gem::Requirement
> have custom marshal methods.
>
>

Excellent! Thanks for the pointer.

--
RMagick: http://rmagick.ruby...

Joel VanderWerf

12/16/2008 6:55:00 PM

0

Tim Hunter wrote:
> Absolutely. I wish I could find some examples of custom
> marshal_dump/marshal_load implementations. Searching thru the
> 1.8.7/1.9.1 sources didn't turn up anything illuminating.

A very simple one:

class C
attr_accessor :x, :y

def marshal_dump
[x, y]
end

def marshal_load(ary)
@x, @y = ary
end
end

c = C.new
c.x = "foo"
c.y = "bar"

s = Marshal.dump(c)
p Marshal.load(s)

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407