Skip to content

Commit

Permalink
Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriprat committed Jul 4, 2015
1 parent 1142e0f commit 1ed50f9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/resque_delay/performable_method.rb
Expand Up @@ -29,9 +29,7 @@ def display_name
end

def perform
ResqueDelay.logger.debug "Loading #{object}"
obj = load(object)
ResqueDelay.logger.debug "Loaded #{obj.to_yaml}"
obj.send(method, *args.map { |a| load(a) })
rescue => e
if defined?(ActiveRecord) && e.kind_of?(ActiveRecord::RecordNotFound)
Expand All @@ -43,17 +41,21 @@ def perform

private

def load(arg)
case arg
def load(arg)
ResqueDelay.logger.debug "Loading #{arg}"
ret = case arg
when CLASS_STRING_FORMAT then $1.constantize
when AR_STRING_FORMAT then $1.constantize.find($2)
when DM_STRING_FORMAT then $1.constantize.get!(*$2.split(':'))
when MG_STRING_FORMAT then $1.constantize.find($2)
else arg
end
ResqueDelay.logger.debug "Loaded #{ret.to_yaml}"
ret
end

def dump(arg)
ResqueDelay.logger.debug "Dumping #{arg}"
if arg.kind_of?(Class) || arg.kind_of?(Module)
class_to_string(arg)
elsif defined?(ActiveRecord) && arg.kind_of?(ActiveRecord::Base)
Expand All @@ -65,6 +67,9 @@ def dump(arg)
else
arg
end
ret = _
ResqueDelay.logger.debug "Dump #{ret}"
ret
end

def mg_to_string(obj)
Expand Down

0 comments on commit 1ed50f9

Please sign in to comment.