Class: ResqueDelay::PerformableMethod
- Inherits:
-
Struct
- Object
- Struct
- ResqueDelay::PerformableMethod
- Defined in:
- lib/resque_delay/performable_method.rb
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, args) ⇒ PerformableMethod
constructor
A new instance of PerformableMethod.
- #perform ⇒ Object
Constructor Details
#initialize(object, method, args) ⇒ PerformableMethod
Returns a new instance of PerformableMethod.
11 12 13 14 15 |
# File 'lib/resque_delay/performable_method.rb', line 11 def initialize(object, method, args) self.object = dump(object) self.args = args.map { |a| dump(a) } self.method = method.to_sym end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
2 3 4 |
# File 'lib/resque_delay/performable_method.rb', line 2 def args @args end |
#method ⇒ Object
Returns the value of attribute method
2 3 4 |
# File 'lib/resque_delay/performable_method.rb', line 2 def method @method end |
#object ⇒ Object
Returns the value of attribute object
2 3 4 |
# File 'lib/resque_delay/performable_method.rb', line 2 def object @object end |
Class Method Details
.create(object, method, args) ⇒ Object
6 7 8 9 |
# File 'lib/resque_delay/performable_method.rb', line 6 def self.create(object, method, args) raise NoMethodError, "undefined method `#{method}' for #{object.inspect}" unless object.respond_to?(method) self.new(object, method, args) end |
Instance Method Details
#display_name ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/resque_delay/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 |
#perform ⇒ Object
25 26 27 28 29 30 |
# File 'lib/resque_delay/performable_method.rb', line 25 def perform load(object).send(method, *args.map{|a| load(a)}) rescue ActiveRecord::RecordNotFound # We cannot do anything about objects which were deleted in the meantime true end |