Sha256: 4306a391ffb11388d7b96e6458e1dac03a27c0c96af405745905aff13555eafe
Contents?: true
Size: 1.09 KB
Versions: 15
Compression:
Stored size: 1.09 KB
Contents
module Delayed class PerformableMethod attr_accessor :object, :method_name, :args def initialize(object, method_name, args) raise NoMethodError, "undefined method `#{method_name}' for #{object.inspect}" unless object.respond_to?(method_name, true) if object.respond_to?(:persisted?) && !object.persisted? raise(ArgumentError, "job cannot be created for non-persisted record: #{object.inspect}") end self.object = object self.args = args self.method_name = method_name.to_sym end def display_name if object.is_a?(Class) "#{object}.#{method_name}" else "#{object.class}##{method_name}" end end def perform object.send(method_name, *args) if object end def method(sym) object.method(sym) end # rubocop:disable MethodMissing def method_missing(symbol, *args) object.send(symbol, *args) end # rubocop:enable MethodMissing def respond_to?(symbol, include_private = false) super || object.respond_to?(symbol, include_private) end end end
Version data entries
15 entries across 15 versions & 1 rubygems