D
Daniel Berger
Hi all,
I was just wondering if there's a way to determine if a string has been
marshalled without visual inspection. Something along the lines of
"string.marshalled?" or "string.kind_of?(MarshaledString)". Is there a
regex I could use?
This had me thinking that it would be nice if Marshal.dump returned a
MarshaledString rather than just a String.
The scenario I'm hitting is a client/server setup where the server may
return a marshaled string or a plain string, depending on the plugin it
calls. At the moment I'm resorting to this, which has potential problems:
r = client.gets
begin
rv = Marshal.load(r)
rescue TypeError
p r
rescue ArgumentError => e
p "R: #{r}"
else
puts rv
end
What do you think?
Regards,
Dan
I was just wondering if there's a way to determine if a string has been
marshalled without visual inspection. Something along the lines of
"string.marshalled?" or "string.kind_of?(MarshaledString)". Is there a
regex I could use?
This had me thinking that it would be nice if Marshal.dump returned a
MarshaledString rather than just a String.
The scenario I'm hitting is a client/server setup where the server may
return a marshaled string or a plain string, depending on the plugin it
calls. At the moment I'm resorting to this, which has potential problems:
r = client.gets
begin
rv = Marshal.load(r)
rescue TypeError
p r
rescue ArgumentError => e
p "R: #{r}"
else
puts rv
end
What do you think?
Regards,
Dan