Module: Orms::ActiveRecordVersion2::DelayedJob::ClassMethods

Defined in:
lib/orms/active_record/version2/delayed_job.rb

Constant Summary collapse

CLASS_STRING_FORMAT =
/^CLASS\:([A-Z][\w\:]+)$/
AR_STRING_FORMAT =
/^AR\:([A-Z][\w\:]+)\:(\d+)$/
LOAD_AR_STRING_FORMAT =
/^LOAD;([A-Z][\w\:]+);(\d+)$/

Instance Method Summary collapse

Instance Method Details

#__delayed_job_ar_to_string_(obj) ⇒ Object



24
25
26
# File 'lib/orms/active_record/version2/delayed_job.rb', line 24

def __delayed_job_ar_to_string_(obj)
  Delayed::PerformableMethod.new(obj, :to_s, []).object
end

#__delayed_job_class_to_string_(obj) ⇒ Object



28
29
30
# File 'lib/orms/active_record/version2/delayed_job.rb', line 28

def __delayed_job_class_to_string_(obj)
  Delayed::PerformableMethod.new(obj, :to_s, []).object
end

#__prepare_yaml_conditions__(yaml_conditions) ⇒ Object



19
20
21
22
# File 'lib/orms/active_record/version2/delayed_job.rb', line 19

def __prepare_yaml_conditions__(yaml_conditions)
  return yaml_conditions if yaml_conditions.has_key?(:handler) || yaml_conditions.has_key?('handler')
  { :handler => yaml_conditions }
end

#__serialize__to_yaml_value__(arg) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/orms/active_record/version2/delayed_job.rb', line 32

def __serialize__to_yaml_value__(arg)
  case arg
    when Class              then __delayed_job_class_to_string_(arg)
    when ActiveRecord::Base then __delayed_job_ar_to_string_(arg)
    else super(arg)
  end
end

#__yaml_load_object_recursively__(arg) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/orms/active_record/version2/delayed_job.rb', line 40

def __yaml_load_object_recursively__(arg)
  case arg
    when CLASS_STRING_FORMAT then $1.constantize
    when AR_STRING_FORMAT    then $1.constantize.find($2)
    when LOAD_AR_STRING_FORMAT then $1.constantize.find($2)
    else super(arg)
  end
end