Class: Delayed::PerformableMethod
- Inherits:
-
Struct
- Object
- Struct
- Delayed::PerformableMethod
- Defined in:
- lib/delayed/performable_method.rb
Defined Under Namespace
Classes: LoadError
Constant Summary collapse
- STRING_FORMAT =
/^LOAD\;([A-Z][\w\:]+)(?:\;(\w+))?$/
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.
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.
18 19 20 21 22 23 24 |
# File 'lib/delayed/performable_method.rb', line 18 def initialize(object, method, args) raise NoMethodError, "undefined method `#{method}' for #{object.inspect}" unless object.respond_to?(method, true) 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
12 13 14 |
# File 'lib/delayed/performable_method.rb', line 12 def args @args end |
#method ⇒ Object
Returns the value of attribute method
12 13 14 |
# File 'lib/delayed/performable_method.rb', line 12 def method @method end |
#object ⇒ Object
Returns the value of attribute object
12 13 14 |
# File 'lib/delayed/performable_method.rb', line 12 def object @object end |
Instance Method Details
#display_name ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/delayed/performable_method.rb', line 26 def display_name if STRING_FORMAT === object "#{$1}#{$2 ? '#' : '.'}#{method}" else "#{object.class}##{method}" end end |
#perform ⇒ Object
34 35 36 37 38 39 |
# File 'lib/delayed/performable_method.rb', line 34 def perform load(object).send(method, *args.map{|a| load(a)}) rescue PerformableMethod::LoadError # We cannot do anything about objects that can't be loaded true end |