Class: Familia::Connection::IndividualCommandProxy
- Inherits:
-
Object
- Object
- Familia::Connection::IndividualCommandProxy
- Defined in:
- lib/familia/connection/individual_command_proxy.rb
Overview
Proxy class that executes Redis commands individually instead of in a transaction
This class intercepts Redis method calls and executes them immediately against the underlying connection, collecting results as if they were part of a transaction. Used as a fallback when transaction mode is unavailable but graceful degradation is preferred over raising an error.
Instance Attribute Summary collapse
-
#collected_results ⇒ Object
readonly
Returns the value of attribute collected_results.
Instance Method Summary collapse
-
#debug_info ⇒ Hash
Returns debug information about the proxy state.
-
#initialize(redis_connection) ⇒ IndividualCommandProxy
constructor
A new instance of IndividualCommandProxy.
-
#method_missing(method_name, *args, **kwargs, &block) ⇒ Object
Intercepts Redis method calls and executes them immediately.
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(redis_connection) ⇒ IndividualCommandProxy
Returns a new instance of IndividualCommandProxy.
27 28 29 30 |
# File 'lib/familia/connection/individual_command_proxy.rb', line 27 def initialize(redis_connection) @connection = redis_connection @collected_results = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, **kwargs, &block) ⇒ Object
Intercepts Redis method calls and executes them immediately
40 41 42 43 44 45 46 47 48 |
# File 'lib/familia/connection/individual_command_proxy.rb', line 40 def method_missing(method_name, *args, **kwargs, &block) if @connection.respond_to?(method_name) result = @connection.public_send(method_name, *args, **kwargs, &block) @collected_results << result result else super end end |
Instance Attribute Details
#collected_results ⇒ Object (readonly)
Returns the value of attribute collected_results.
25 26 27 |
# File 'lib/familia/connection/individual_command_proxy.rb', line 25 def collected_results @collected_results end |
Instance Method Details
#debug_info ⇒ Hash
Returns debug information about the proxy state
57 58 59 60 61 62 63 |
# File 'lib/familia/connection/individual_command_proxy.rb', line 57 def debug_info { connection_class: @connection.class.name, results_count: @collected_results.size, results: @collected_results.dup } end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
50 51 52 |
# File 'lib/familia/connection/individual_command_proxy.rb', line 50 def respond_to_missing?(method_name, include_private = false) @connection.respond_to?(method_name, include_private) || super end |