Sha256: 44ed054a82f5da1acb1e700e7afe7f39e0681cf2e91694b3545f89cbdcb8c2fb

Contents?: true

Size: 719 Bytes

Versions: 1

Compression:

Stored size: 719 Bytes

Contents

class Kredis::Types::Proxy
  attr_accessor :redis, :key

  def initialize(redis, key, **options)
    @redis, @key = redis, key
    options.each { |key, value| send("#{key}=", value) }
  end

  def multi(...)
    redis.multi(...)
  end

  def method_missing(method, *args, **kwargs)
    Kredis.logger&.debug log_message(method, *args, **kwargs)
    redis.public_send method, key, *args, **kwargs
  end

  private
    def log_message(method, *args, **kwargs)
      args      = args.flatten.compact_blank.presence
      kwargs    = kwargs.compact_blank.presence
      type_name = self.class.name.split("::").last

      "[Kredis #{type_name}] #{method.upcase} #{key} #{args&.inspect} #{kwargs&.inspect}".chomp
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kredis-0.2.0 lib/kredis/types/proxy.rb