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.



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

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



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

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