Sha256: 2574aa634b477645af69faa61937f36ef3c77ce6be29a19259a3d59b4b530e98

Contents?: true

Size: 679 Bytes

Versions: 3

Compression:

Stored size: 679 Bytes

Contents

# frozen_string_literal: true

module ActiveRedisStats
  module Rank
    class Set < ActiveRedisStats::Rank::Base

      class << self
        %i[decrement increment].each do |meth|
          define_method(meth) do |key, val, by: 1|
            ActiveRedisDB::SortedSet
              .send(meth, primary_key(key), val.to_s, by)
          end

          define_method("#{meth}_intervals") do |key, val, by: 1|
            ActiveRedisStats::Base::EXPIRES.each do |frmt, secs|
              ikey = "#{key}:#{interval_key(frmt)}"

              send(meth, ikey, val, by: by)
              expiration(ikey, secs)
            end
          end
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_redis_stats-0.1.3 lib/active_redis_stats/rank/set.rb
active_redis_stats-0.1.2 lib/active_redis_stats/rank/set.rb
active_redis_stats-0.1.1 lib/active_redis_stats/rank/set.rb