Class: Naught::ChainProxy Private
- Inherits:
- BasicObject
- Defined in:
- lib/naught/chain_proxy.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Lightweight proxy for tracking chained method calls
Used by the callstack feature to group chained method calls
(e.g., null.foo.bar.baz) into a single trace while keeping
separate calls (e.g., null.foo; null.bar) in separate traces.
Instance Method Summary collapse
-
#class ⇒ Class
private
Return the class of the root null object.
-
#initialize(root, current_trace) ⇒ ChainProxy
constructor
private
Create a new ChainProxy.
-
#inspect ⇒ String
private
Return a string representation of the proxy.
-
#method_missing(method_name, *args) ⇒ ChainProxy
private
Handle method calls by recording them and returning self for chaining.
-
#respond_to? ⇒ true
private
Check if the proxy responds to a method.
Constructor Details
#initialize(root, current_trace) ⇒ ChainProxy
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new ChainProxy
16 17 18 19 |
# File 'lib/naught/chain_proxy.rb', line 16 def initialize(root, current_trace) @root = root @current_trace = current_trace end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ ChainProxy
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Handle method calls by recording them and returning self for chaining
rubocop:disable Style/MissingRespondToMissing -- BasicObject doesn't use respond_to_missing?
27 28 29 30 31 32 33 |
# File 'lib/naught/chain_proxy.rb', line 27 def method_missing(method_name, *args) location = ::Naught::CallLocation.from_caller( method_name, args, ::Kernel.caller(1, 1).first ) @current_trace << location self end |
Instance Method Details
#class ⇒ Class
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the class of the root null object
49 |
# File 'lib/naught/chain_proxy.rb', line 49 def class = @root.class |
#inspect ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return a string representation of the proxy
44 |
# File 'lib/naught/chain_proxy.rb', line 44 def inspect = "<null:chain>" |
#respond_to? ⇒ true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if the proxy responds to a method
39 |
# File 'lib/naught/chain_proxy.rb', line 39 def respond_to?(*, **) = true |