Module: YAML

Defined in:
lib/feed_tools/monkey_patch.rb

Class Method Summary collapse

Class Method Details

.dump(obj, io = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/feed_tools/monkey_patch.rb', line 5

def YAML.dump( obj, io = nil )
  if obj.kind_of?(FeedTools::Feed) || obj.kind_of?(FeedTools::FeedItem)
    # Dangit, you WILL NOT serialize these things.
    obj.instance_variable_set("@xml_document", nil)
    obj.instance_variable_set("@root_node", nil)
    obj.instance_variable_set("@channel_node", nil)
  end
   obj.to_yaml( io || io2 = StringIO.new )
   io || ( io2.rewind; io2.read )
end

.load(io) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/feed_tools/monkey_patch.rb', line 16

def YAML.load( io )
	yp = parser.load( io )
  if yp.kind_of?(FeedTools::Feed) || yp.kind_of?(FeedTools::FeedItem)
    # No really, I'm serious, you WILL NOT deserialize these things.
    yp.instance_variable_set("@xml_document", nil)
    yp.instance_variable_set("@root_node", nil)
    yp.instance_variable_set("@channel_node", nil)
  end
  yp
end