Class: ObjectInspector::ObjectInterrogator
- Inherits:
-
Object
- Object
- ObjectInspector::ObjectInterrogator
- Defined in:
- lib/object_inspector/object_interrogator.rb
Overview
ObjectInspector::ObjectInterrogator collaborates with #object to return Object##method_name if #object responds to the method.
If Object##method_name accepts the supplied #kargs then they are passed in as well. If not, then any supplied #kargs will be ignored.
Instance Attribute Summary collapse
-
#kargs ⇒ Object
readonly
Returns the value of attribute kargs.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#call ⇒ String, ...
Whatever type Object##method returns.
-
#initialize(object:, method_name:, kargs: {}) ⇒ ObjectInterrogator
constructor
A new instance of ObjectInterrogator.
Constructor Details
#initialize(object:, method_name:, kargs: {}) ⇒ ObjectInterrogator
14 15 16 17 18 |
# File 'lib/object_inspector/object_interrogator.rb', line 14 def initialize(object:, method_name:, kargs: {}) @object = object @method_name = method_name @kargs = kargs end |
Instance Attribute Details
#kargs ⇒ Object (readonly)
Returns the value of attribute kargs.
10 11 12 |
# File 'lib/object_inspector/object_interrogator.rb', line 10 def kargs @kargs end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
10 11 12 |
# File 'lib/object_inspector/object_interrogator.rb', line 10 def method_name @method_name end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
10 11 12 |
# File 'lib/object_inspector/object_interrogator.rb', line 10 def object @object end |
Instance Method Details
#call ⇒ String, ...
Returns whatever type Object##method returns.
24 25 26 27 28 29 30 31 32 |
# File 'lib/object_inspector/object_interrogator.rb', line 24 def call return unless object_responds_to_method_name? if object.method(method_name).arity != 0 call_with_kargs else object.send(method_name) end end |