|
Revision 326, 0.6 kB
(checked in by gethema..@gmail.com, 6 months ago)
|
check in new backgroundrb code
|
| Line | |
|---|
| 1 |
module BackgrounDRb |
|---|
| 2 |
module BdrbServerHelper |
|---|
| 3 |
# Load data using Marshal.load, if load fails because of undefined constant |
|---|
| 4 |
# try to load the constant. FIXME: regexp needs to handle all the cases. |
|---|
| 5 |
def load_data data |
|---|
| 6 |
begin |
|---|
| 7 |
return Marshal.load(data) |
|---|
| 8 |
rescue |
|---|
| 9 |
error_msg = $!.message |
|---|
| 10 |
if error_msg =~ |
|---|
| 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 |
|---|
| 23 |
end |
|---|
| 24 |
end |
|---|