Methods

BackgrounDRb::BdrbServerHelper

Public Instance Methods

load_data(data) click to toggle source

Load data using Marshal.load, if load fails because of undefined constant try to load the constant. FIXME: regexp needs to handle all the cases.

    # File server/lib/bdrb_server_helper.rb, line 5
 5:     def load_data data
 6:       begin
 7:         return Marshal.load(data)
 8:       rescue
 9:         error_msg = $!.message
10:         if error_msg =~ /^undefined\ .+\ ([A-Z].+)/
11:           file_name = $1.underscore
12:           begin
13:             require file_name
14:             return Marshal.load(data)
15:           rescue
16:             return nil
17:           end
18:         else
19:           return nil
20:         end
21:       end # end of load_data method
22:     end

secsequence

--- SEC00025

seccomment

--- ""

method_list

--- 
- methods: 
  - visibility: public
    aref: M000010
    name: load_data
    sourcecode: "    <span class=\"ruby-comment cmt\"># File server/lib/bdrb_server_helper.rb, line 5</span>\n 5:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">load_data</span> <span class=\"ruby-identifier\">data</span>\n 6:       <span class=\"ruby-keyword kw\">begin</span>\n 7:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-constant\">Marshal</span>.<span class=\"ruby-identifier\">load</span>(<span class=\"ruby-identifier\">data</span>)\n 8:       <span class=\"ruby-keyword kw\">rescue</span>\n 9:         <span class=\"ruby-identifier\">error_msg</span> = <span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">message</span>\n\
      10:         <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">error_msg</span> <span class=\"ruby-operator\">=~</span> <span class=\"ruby-regexp re\">/^undefined\\ .+\\ ([A-Z].+)/</span>\n\
      11:           <span class=\"ruby-identifier\">file_name</span> = <span class=\"ruby-identifier\">$1</span>.<span class=\"ruby-identifier\">underscore</span>\n\
      12:           <span class=\"ruby-keyword kw\">begin</span>\n\
      13:             <span class=\"ruby-identifier\">require</span> <span class=\"ruby-identifier\">file_name</span>\n\
      14:             <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-constant\">Marshal</span>.<span class=\"ruby-identifier\">load</span>(<span class=\"ruby-identifier\">data</span>)\n\
      15:           <span class=\"ruby-keyword kw\">rescue</span>\n\
      16:             <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">nil</span>\n\
      17:           <span class=\"ruby-keyword kw\">end</span>\n\
      18:         <span class=\"ruby-keyword kw\">else</span>\n\
      19:           <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">nil</span>\n\
      20:         <span class=\"ruby-keyword kw\">end</span>\n\
      21:       <span class=\"ruby-keyword kw\">end</span> <span class=\"ruby-comment cmt\"># end of load_data method</span>\n\
      22:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Load data using Marshal.load, if load fails because of undefined constant
      try to load the constant. FIXME: regexp needs to handle all the cases.
      </p>
    params: (data)
  category: Instance
  type: Public

sectitle

--- 

[Validate]

Generated with the Darkfish Rdoc Generator.