Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve PerformableMethod logging #1187

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/delayed/message_sending.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def initialize(payload_class, target, options)
end

# rubocop:disable MethodMissing
def method_missing(method, *args)
Job.enqueue({:payload_object => @payload_class.new(@target, method.to_sym, args)}.merge(@options))
def method_missing(method, *args, &block)
Job.enqueue({:payload_object => @payload_class.new(@target, method.to_sym, args, &block)}.merge(@options))
end
# rubocop:enable MethodMissing
end
Expand Down
3 changes: 2 additions & 1 deletion lib/delayed/performable_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ module Delayed
class PerformableMethod
attr_accessor :object, :method_name, :args

def initialize(object, method_name, args)
def initialize(object, method_name, args, &block)
raise NoMethodError, "undefined method `#{method_name}' for #{object.inspect}" unless object.respond_to?(method_name, true)
warn "Ignored the block #{block.inspect} because it cannot be serialized." if block_given?

if object.respond_to?(:persisted?) && !object.persisted?
raise(ArgumentError, "job cannot be created for non-persisted record: #{object.inspect}")
Expand Down