class FetchUrlJob Struct new thread_id def perform thread Thread find

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
>> class FetchUrlJob < Struct.new(:thread_id)
>> def perform
>> thread = Thread.find(thread_id)
>> file = some_http_fetch_method(thread.url)
>> file.save
>> thread.file_path = file.real_path_name
>> thread.save
>> end
>> end
=> nil
>> fj = FetchUrlJob.new(123)
=> #<struct FetchUrlJob thread_id=123>
>> Marshal.dump
Marshal.dump
>> Marshal.dump(fj)
=> "\004\bS:\020FetchUrlJob\006:\016thread_idi\001{"
>>
?>
?> ^C
>> fj_dump = Marshal.dump(fj)
=> "\004\bS:\020FetchUrlJob\006:\016thread_idi\001{"
>> fj_resurected = Marshal.load(fj_dump)
=> #<struct FetchUrlJob thread_id=123>
>> fj_resurected.thread_id
=> 123
>>