static public Method

Convert.struct(hash)

There's no documentation for this item.

Source Code

# File xmlrpc/parser.rb, line 122
def self.struct(hash)
  # convert to marhalled object
  klass = hash["___class___"]
  if klass.nil? or Config::ENABLE_MARSHALLING == false 
    hash
  else
    begin
      mod = Module
      klass.split("::").each {|const| mod = mod.const_get(const.strip)}

      obj = mod.allocate

      hash.delete "___class___"
      hash.each {|key, value| 
        obj.instance_variable_set("@#{ key }", value) if key =~ /^([\w_][\w_0-9]*)$/
      }
      obj
    rescue
      hash
    end
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.