Class: DelayedResque::PerformableMethod
- Inherits:
-
Struct
- Object
- Struct
- DelayedResque::PerformableMethod
- Defined in:
- lib/delayed_resque/performable_method.rb
Direct Known Subclasses
Constant Summary collapse
- CLASS_STRING_FORMAT =
/^CLASS\:([A-Z][\w\:]+)$/- AR_STRING_FORMAT =
/^AR\:([A-Z][\w\:]+)\:(\d+)$/
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#method ⇒ Object
Returns the value of attribute method.
-
#object ⇒ Object
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
- #display_name ⇒ Object
-
#initialize(object, method, options, args) ⇒ PerformableMethod
constructor
A new instance of PerformableMethod.
- #store ⇒ Object
Constructor Details
#initialize(object, method, options, args) ⇒ PerformableMethod
Returns a new instance of PerformableMethod.
8 9 10 11 12 13 14 15 |
# File 'lib/delayed_resque/performable_method.rb', line 8 def initialize(object, method, , args) raise NoMethodError, "undefined method `#{method}' for #{object.inspect}" unless object.respond_to?(method,true) @object = dump(object) @method = method.to_sym = @args = args.map { |a| dump(a) } end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
4 5 6 |
# File 'lib/delayed_resque/performable_method.rb', line 4 def args @args end |
#method ⇒ Object
Returns the value of attribute method
4 5 6 |
# File 'lib/delayed_resque/performable_method.rb', line 4 def method @method end |
#object ⇒ Object
Returns the value of attribute object
4 5 6 |
# File 'lib/delayed_resque/performable_method.rb', line 4 def object @object end |
Class Method Details
.perform(options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/delayed_resque/performable_method.rb', line 29 def self.perform() object = ["obj"] method = ["method"] args = ["args"] self.load(object).send(method, *args.map{|a| self.load(a)}) rescue ActiveRecord::RecordNotFound Rails.logger.warn("PerformableMethod: failed to find record for #{object.inspect}") # We cannot do anything about objects which were deleted in the meantime true end |
.queue ⇒ Object
25 26 27 |
# File 'lib/delayed_resque/performable_method.rb', line 25 def self.queue "default" end |
Instance Method Details
#display_name ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/delayed_resque/performable_method.rb', line 17 def display_name case self.object when CLASS_STRING_FORMAT then "#{$1}.#{method}" when AR_STRING_FORMAT then "#{$1}##{method}" else "Unknown##{method}" end end |
#store ⇒ Object
40 41 42 |
# File 'lib/delayed_resque/performable_method.rb', line 40 def store {"obj" => @object, "method" => @method, "args" => @args}.merge([:params] || {}) end |