From: Ryan Davis Date: 2009-11-14T08:04:38+09:00 Subject: Re: YAML dump, load: class not properly reconstituted On Nov 13, 2009, at 12:58 , Pito Salas wrote: > 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: > > # > {:filename=> > # @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: > #!/usr/bin/ruby -w > > require 'yaml' > require 'pathname' > > # I had to fix your YAML indentation > 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 > " > > 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: > #"/mydev/ballots/432Leon200dpibw001.tif"}>