T
Travis Smith
I have a class which when YAMLized produces...
--- !ruby/object
layer
name: dude
password: dude
session: !ruby/object:TCPSocket {}
thread: !ruby/object:Thread {}
I'd like to figure out a way for it to just ignore the Thread and/or
TCPSocket type. It won't choke on the socket, but it will loading up
the Thread. Can I add a domain type that will just produce nil not
matter what happens?
irb(main):019:0> YAML::add_domain_type("legomaster.net,2005-03",
/Thread/) { | type, val | nil }
=> nil
irb(main):020:0> temp = YAML.load_file('data/players/dude.o')
TypeError: allocator undefined for Thread
from /usr/local/lib/ruby/1.8/yaml.rb:347:in `allocate'
from /usr/local/lib/ruby/1.8/yaml.rb:347:in `object_maker'
from /usr/local/lib/ruby/1.8/yaml/rubytypes.rb:36
from /usr/local/lib/ruby/1.8/yaml/rubytypes.rb:34:in `call'
from (irb):20:in `transfer'
from /usr/local/lib/ruby/1.8/yaml.rb:119:in `load'
from /usr/local/lib/ruby/1.8/yaml.rb:119:in `load'
from /usr/local/lib/ruby/1.8/yaml.rb:130:in `load_file'
from /usr/local/lib/ruby/1.8/yaml.rb:129:in `open'
from /usr/local/lib/ruby/1.8/yaml.rb:129:in `load_file'
from (irb):20
irb(main):021:0>
Thanks, it would much easier if I didn't have to end up writing my own parser.
~Travis Smith
--- !ruby/object
name: dude
password: dude
session: !ruby/object:TCPSocket {}
thread: !ruby/object:Thread {}
I'd like to figure out a way for it to just ignore the Thread and/or
TCPSocket type. It won't choke on the socket, but it will loading up
the Thread. Can I add a domain type that will just produce nil not
matter what happens?
irb(main):019:0> YAML::add_domain_type("legomaster.net,2005-03",
/Thread/) { | type, val | nil }
=> nil
irb(main):020:0> temp = YAML.load_file('data/players/dude.o')
TypeError: allocator undefined for Thread
from /usr/local/lib/ruby/1.8/yaml.rb:347:in `allocate'
from /usr/local/lib/ruby/1.8/yaml.rb:347:in `object_maker'
from /usr/local/lib/ruby/1.8/yaml/rubytypes.rb:36
from /usr/local/lib/ruby/1.8/yaml/rubytypes.rb:34:in `call'
from (irb):20:in `transfer'
from /usr/local/lib/ruby/1.8/yaml.rb:119:in `load'
from /usr/local/lib/ruby/1.8/yaml.rb:119:in `load'
from /usr/local/lib/ruby/1.8/yaml.rb:130:in `load_file'
from /usr/local/lib/ruby/1.8/yaml.rb:129:in `open'
from /usr/local/lib/ruby/1.8/yaml.rb:129:in `load_file'
from (irb):20
irb(main):021:0>
Thanks, it would much easier if I didn't have to end up writing my own parser.
~Travis Smith