Class: Delayed::PerformableMethod
- Defined in:
- lib/delayed/performable_method.rb
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.
- #method_missing(symbol, *args) ⇒ Object
- #perform ⇒ Object
- #respond_to?(symbol, include_private = false) ⇒ Boolean
Methods inherited from Struct
Constructor Details
#initialize(object, method, args) ⇒ PerformableMethod
Returns a new instance of PerformableMethod.
3 4 5 6 7 8 9 |
# File 'lib/delayed/performable_method.rb', line 3 def initialize(object, method, args) raise NoMethodError, "undefined method `#{method}' for #{object.inspect}" unless object.respond_to?(method, true) self.object = object self.args = args self.method = method.to_sym end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
19 20 21 |
# File 'lib/delayed/performable_method.rb', line 19 def method_missing(symbol, *args) object.respond_to?(symbol) ? object.send(symbol, *args) : super end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
2 3 4 |
# File 'lib/delayed/performable_method.rb', line 2 def args @args end |
#method ⇒ Object
Returns the value of attribute method
2 3 4 |
# File 'lib/delayed/performable_method.rb', line 2 def method @method end |
#object ⇒ Object
Returns the value of attribute object
2 3 4 |
# File 'lib/delayed/performable_method.rb', line 2 def object @object end |
Instance Method Details
#display_name ⇒ Object
11 12 13 |
# File 'lib/delayed/performable_method.rb', line 11 def display_name "#{object.class}##{method}" end |
#perform ⇒ Object
15 16 17 |
# File 'lib/delayed/performable_method.rb', line 15 def perform object.send(method, *args) if object end |
#respond_to?(symbol, include_private = false) ⇒ Boolean
23 24 25 |
# File 'lib/delayed/performable_method.rb', line 23 def respond_to?(symbol, include_private=false) object.respond_to?(symbol, include_private) || super end |