Class: Delayed::PerformableMethod
- Defined in:
- lib/delayed/performable_method.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#object ⇒ Object
Returns the value of attribute object.
Instance Method Summary collapse
- #display_name ⇒ Object
-
#initialize(object, method_name, 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_name, args) ⇒ PerformableMethod
Returns a new instance of PerformableMethod.
7 8 9 10 11 12 13 |
# File 'lib/delayed/performable_method.rb', line 7 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
23 24 25 |
# File 'lib/delayed/performable_method.rb', line 23 def method_missing(symbol, *args) object.send(symbol, *args) end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
4 5 6 |
# File 'lib/delayed/performable_method.rb', line 4 def args @args end |
#method_name ⇒ Object
Returns the value of attribute method_name
4 5 6 |
# File 'lib/delayed/performable_method.rb', line 4 def method_name @method_name end |
#object ⇒ Object
Returns the value of attribute object
4 5 6 |
# File 'lib/delayed/performable_method.rb', line 4 def object @object end |
Instance Method Details
#display_name ⇒ Object
15 16 17 |
# File 'lib/delayed/performable_method.rb', line 15 def display_name "#{object.class}##{method_name}" end |
#perform ⇒ Object
19 20 21 |
# File 'lib/delayed/performable_method.rb', line 19 def perform object.send(method_name, *args) if object end |
#respond_to?(symbol, include_private = false) ⇒ Boolean
27 28 29 |
# File 'lib/delayed/performable_method.rb', line 27 def respond_to?(symbol, include_private=false) super || object.respond_to?(symbol, include_private) end |