Module: ResqueDelayable

Defined in:
lib/resque-delayable.rb,
lib/resque-delayable/version.rb,
lib/resque-delayable/delayed_method.rb,
lib/resque-delayable/serializer/mongoid_serializer.rb,
lib/resque-delayable/serializer/mongo_mapper_serializer.rb,
lib/resque-delayable/serializer/active_record_serializer.rb

Defined Under Namespace

Modules: ClassMethods, Serializer Classes: DelayedMethod

Constant Summary collapse

ACTIVE_SERIALIZERS =
Set.new
VERSION =
File.read(File.join(File.dirname(__FILE__), "../../VERSION"))

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deserialize_object(object) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/resque-delayable.rb', line 27

def self.deserialize_object(object)
  if [Hash, HashWithIndifferentAccess].include?(object.class)
    object.inject({}) {|doc, (k,v)| doc[k] = deserialize_object(v); doc}
  elsif [Set, Array].include?(object.class)
    object.map {|v| deserialize_object(v)}
  else
    ACTIVE_SERIALIZERS.each do |serializer|
      return serializer.deserialize(object) if serializer.deserialize_match(object)
    end

    object
  end
end

.included(base) ⇒ Object



8
9
10
11
# File 'lib/resque-delayable.rb', line 8

def self.included(base)
  base.extend(ClassMethods)
  super
end

.serialize_object(object) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/resque-delayable.rb', line 13

def self.serialize_object(object)
  if [Hash, HashWithIndifferentAccess].include?(object.class)
    object.inject({}) {|doc, (k,v)| doc[k] = serialize_object(v); doc}
  elsif [Set, Array].include?(object.class)
    object.map {|v| serialize_object(v)}
  else
    ACTIVE_SERIALIZERS.each do |serializer|
      return serializer.serialize(object) if serializer.serialize_match(object)
    end
    
    object
  end
end

Instance Method Details

#rdelay(options = {}) ⇒ Object



68
69
70
# File 'lib/resque-delayable.rb', line 68

def rdelay(options = {})
  return DelayedMethod.new(self.class, self, options)
end