# YAML dump, load: class not properly reconstituted

**URL:** <https://www.ruby-forum.com/t/yaml-dump-load-class-not-properly-reconstituted/178943>\
**Category:** Ruby\
**Created:** [November 13, 2009, 9:58pm UTC](https://www.ruby-forum.com/t/yaml-dump-load-class-not-properly-reconstituted/178943 "2009-11-13T21:58:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [November 13, 2009, 9:58pm UTC](https://www.ruby-forum.com/t/yaml-dump-load-class-not-properly-reconstituted/178943/1 "2009-11-13T21:58:24Z")

</div>

Here’s some yaml:

* * *

- :status: :failure  
:filename: !ruby/object:Pathname  
path: /mydev/ballots/432Leon200dpibw001.tif
- :status: :failure  
:skew\_angle: -0.72217746154481  
:rotated: -0.72217746154481  
:filename: !ruby/object:Pathname  
path: /mydev/ballots/432Leon200dpibw002.tif

When I load this back into Ruby, I get something like this from pp:

#\<PBScorer:0x1010d9bc8

{:filename=\>  
#\<Pathname:0x1010d5370  
@class=“Pathname”,  
@ivars=  
{“path”=\>"/mydev/iaharness/ballotsamples/432Leon200dpibw003.tif"}\>}  
…

In the debugger, the class of :filename seems to be YAML::something

So, it looks like the re-encoding of Pathname by Yaml got a bit  
flumoxed. I’ve tried a bunch of small examples and can’t seem to get it  
to reproduce.

Anyone spot whats wrong before I go deeper and deeper and depper?

Thanks,

Pito

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [November 14, 2009, 12:05am UTC](https://www.ruby-forum.com/t/yaml-dump-load-class-not-properly-reconstituted/178943/2 "2009-11-14T00:05:01Z")

</div>

On Nov 13, 2009, at 12:58 , Pito S. wrote:

> path: /mydev/ballots/432Leon200dpibw002.tif
> 
> When I load this back into Ruby, I get something like this from pp:
> 
> #\<PBScorer:0x1010d9bc8
> 
> {:filename=\>  
> #\<Pathname:0x1010d5370  
> @class=“Pathname”,  
> @ivars=  
> {“path”=\>"/mydev/iaharness/ballotsamples/432Leon200dpibw003.tif"}\>}

I suspect you’re not telling us all the relevant details. The following  
code works fine:

> - :status: :failure  
> :skew\_angle: -0.72217746154481  
> :rotated: -0.72217746154481  
> :filename: !ruby/object:Pathname  
> path: /mydev/ballots/432Leon200dpibw002.tif  
> "
> 
> array = YAML.load(StringIO.new(yaml))
> 
> p array.first[:filename].absolute? # =\> true

If you comment out the pathname require, then it is a YAML object but it  
is obvious about it:
