Class: MimeActor::Dispatcher::MethodCall
- Inherits:
-
Object
- Object
- MimeActor::Dispatcher::MethodCall
- Defined in:
- lib/mime_actor/dispatcher.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Instance Method Summary collapse
- #call(target) ⇒ Object
-
#initialize(method_name, *args) ⇒ MethodCall
constructor
A new instance of MethodCall.
Constructor Details
#initialize(method_name, *args) ⇒ MethodCall
Returns a new instance of MethodCall.
12 13 14 15 16 |
# File 'lib/mime_actor/dispatcher.rb', line 12 def initialize(method_name, *args) @method_name = method_name @args = args validate! end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/mime_actor/dispatcher.rb', line 10 def args @args end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
10 11 12 |
# File 'lib/mime_actor/dispatcher.rb', line 10 def method_name @method_name end |
Instance Method Details
#call(target) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/mime_actor/dispatcher.rb', line 18 def call(target) raise MimeActor::ActorNotFound, method_name unless target.respond_to?(method_name, true) method_call = target.method(method_name) filtered_args = method_call.arity.negative? ? args : args.take(method_call.arity) method_call.call(*filtered_args) end |