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+)$/

Instance Method Summary collapse

Instance Method Details

#__delayed_job_ar_to_string_(obj) ⇒ Object



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

def __delayed_job_ar_to_string_(obj)
  "AR:#{obj.class}:#{obj.id}"
end

#__delayed_job_class_to_string_(obj) ⇒ Object



22
23
24
# File 'lib/orms/active_record/version2/delayed_job.rb', line 22

def __delayed_job_class_to_string_(obj)
  "CLASS:#{obj.name}"
end

#__serialize__to_yaml_value__(arg) ⇒ Object



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

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



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

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