Sha256: 0df37c4c84735a6f71a9e57158ff7134d5650ea07179213fbdb4c56a0ae08db6

Contents?: true

Size: 825 Bytes

Versions: 10

Compression:

Stored size: 825 Bytes

Contents

require 'active_support/core_ext/module/delegation'

module Delayed
  class PerformableMethod
    attr_accessor :object, :method_name, :args

    delegate :method, :to => :object

    def initialize(object, method_name, args)
      raise NoMethodError, "undefined method `#{method_name}' for #{object.inspect}" unless object.respond_to?(method_name, true)

      self.object       = object
      self.args         = args
      self.method_name  = method_name.to_sym
    end

    def display_name
      "#{object.class}##{method_name}"
    end

    def perform
      object.send(method_name, *args) if object
    end

    def method_missing(symbol, *args)
      object.send(symbol, *args)
    end

    def respond_to?(symbol, include_private=false)
      super || object.respond_to?(symbol, include_private)
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
delayed_job_unique_key-0.0.4 lib/delayed/performable_method.rb
delayed_job-3.0.1 lib/delayed/performable_method.rb
delayed_job-3.0.0 lib/delayed/performable_method.rb
delayed_job_unique_key-0.0.3 lib/delayed/performable_method.rb
delayed_job_unique_key-0.0.2 lib/delayed/performable_method.rb
delayed_job_unique_key-0.0.1 lib/delayed/performable_method.rb
delayed_job-3.0.0.pre4 lib/delayed/performable_method.rb
delayed_job-3.0.0.pre3 lib/delayed/performable_method.rb
delayed_job-3.0.0.pre2 lib/delayed/performable_method.rb
delayed_job-3.0.0.pre lib/delayed/performable_method.rb