Class: Kredis::Types::Proxy
- Inherits:
-
Object
- Object
- Kredis::Types::Proxy
- Includes:
- Failsafe
- Defined in:
- lib/kredis/types/proxy.rb
Defined Under Namespace
Modules: Failsafe
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
-
#initialize(redis, key, **options) ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(method, *args, **kwargs) ⇒ Object
- #multi(&block) ⇒ Object
Methods included from Failsafe
#failsafe, #suppress_failsafe_with
Constructor Details
#initialize(redis, key, **options) ⇒ Proxy
7 8 9 10 |
# File 'lib/kredis/types/proxy.rb', line 7 def initialize(redis, key, **) @redis, @key = redis, key .each { |key, value| send("#{key}=", value) } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, **kwargs) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/kredis/types/proxy.rb', line 21 def method_missing(method, *args, **kwargs) Kredis.instrument :proxy, **(method, *args, **kwargs) do failsafe do redis.public_send method, key, *args, **kwargs end end end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
5 6 7 |
# File 'lib/kredis/types/proxy.rb', line 5 def key @key end |
#redis ⇒ Object
Returns the value of attribute redis.
5 6 7 |
# File 'lib/kredis/types/proxy.rb', line 5 def redis @redis end |
Instance Method Details
#multi(&block) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/kredis/types/proxy.rb', line 12 def multi(&block) # NOTE: to be removed when Redis 4 compatibility gets dropped return redis.multi unless block redis.multi do |pipeline| block.call(Kredis::Types::Proxy.new(pipeline, key)) end end |