lib/rekiq/job.rb in rekiq-0.9.2 vs lib/rekiq/job.rb in rekiq-0.9.3
- old
+ new
@@ -1,6 +1,5 @@
-require 'yaml'
require 'rekiq/validator'
require 'rekiq/configuration'
module Rekiq
class Job
@@ -13,20 +12,19 @@
validate :shift, :numeric, allow_nil: true
validate :schedule_post_work, :bool, allow_nil: true
validate :schedule_expired, :numeric, allow_nil: true
validate :expiration_margin, :bool, allow_nil: true
- def self.from_array(array)
- attributes = {}.tap do |hash|
- hash['schedule'] = YAML::load(array[0])
- hash['shift'] = array[1]
- hash['schedule_post_work'] = array[2]
- hash['schedule_expired'] = array[3]
- hash['expiration_margin'] = array[4]
- end
-
- new(attributes)
+ class << self
+ def from_array(array)
+ new \
+ 'schedule' => Marshal.load(array[0].encode('ISO-8859-1')),
+ 'shift' => array[1],
+ 'schedule_post_work' => array[2],
+ 'schedule_expired' => array[3],
+ 'expiration_margin' => array[4]
+ end
end
def initialize(attributes = {})
self.schedule = attributes['schedule']
self.shift = attributes['shift']
@@ -35,10 +33,10 @@
self.expiration_margin = attributes['expiration_margin']
end
def to_array
[
- YAML::dump(schedule),
+ Marshal.dump(schedule).force_encoding('ISO-8859-1').encode('UTF-8'),
shift,
schedule_post_work,
schedule_expired,
expiration_margin
]
\ No newline at end of file