Class: Kredis::Types::CallbacksProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/kredis/types/callbacks_proxy.rb

Constant Summary collapse

AFTER_CHANGE_OPERATIONS =
{
  Kredis::Types::Counter => %i[ increment decrement reset ],
  Kredis::Types::Cycle => %i[ next ],
  Kredis::Types::Enum => %i[ value= reset ],
  Kredis::Types::Flag => %i[ mark remove ],
  Kredis::Types::Hash => %i[ update delete ],
  Kredis::Types::List => %i[ remove prepend append << ],
  Kredis::Types::Scalar => %i[ value= clear ],
  Kredis::Types::Set => %i[ add << remove replace take clear ],
  Kredis::Types::Slots => %i[ reserve release reset ]
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, callback) ⇒ CallbacksProxy

Returns a new instance of CallbacksProxy.



17
18
19
# File 'lib/kredis/types/callbacks_proxy.rb', line 17

def initialize(type, callback)
  @type, @callback = type, callback
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, **kwargs, &block) ⇒ Object



21
22
23
24
25
# File 'lib/kredis/types/callbacks_proxy.rb', line 21

def method_missing(method, *args, **kwargs, &block)
  result = type.send(method, *args, **kwargs, &block)
  invoke_suitable_after_change_callback_for method
  result
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



2
3
4
# File 'lib/kredis/types/callbacks_proxy.rb', line 2

def type
  @type
end