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 reset ],
  Kredis::Types::Enum => %i[ value= reset ],
  Kredis::Types::Flag => %i[ mark remove ],
  Kredis::Types::Hash => %i[ update delete []= remove ],
  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 ],
  Kredis::Types::UniqueList => %i[ remove prepend append << ]
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, callback) ⇒ CallbacksProxy

Returns a new instance of CallbacksProxy.



20
21
22
# File 'lib/kredis/types/callbacks_proxy.rb', line 20

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



24
25
26
27
28
# File 'lib/kredis/types/callbacks_proxy.rb', line 24

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.



4
5
6
# File 'lib/kredis/types/callbacks_proxy.rb', line 4

def type
  @type
end