Sha256: 9b46e1c380cc6925185e0341665b7986323d55a4226a9cde40eb5144d2b96386

Contents?: true

Size: 461 Bytes

Versions: 10

Compression:

Stored size: 461 Bytes

Contents

# frozen_string_literal: true

require 'cacchern/sorted_set'

module Cacchern
  class IncrementableSortedSet < Cacchern::SortedSet
    def increment(value)
      return false unless value.instance_of?(self.class.contain_class)

      if value.valid?
        Redis.current.zincrby @key, value.value, value.key
        true
      else
        false
      end
    end

    def increment_all(values)
      values.each { |value| increment(value) }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cacchern-0.0.11 lib/cacchern/incrementable_sorted_set.rb
cacchern-0.0.10 lib/cacchern/incrementable_sorted_set.rb
cacchern-0.0.9 lib/cacchern/incrementable_sorted_set.rb
cacchern-0.0.8 lib/cacchern/incrementable_sorted_set.rb
cacchern-0.0.7 lib/cacchern/incrementable_sorted_set.rb
cacchern-0.0.6 lib/cacchern/incrementable_sorted_set.rb
cacchern-0.0.5 lib/cacchern/incrementable_sorted_set.rb
cacchern-0.0.4 lib/cacchern/incrementable_sorted_set.rb
cacchern-0.0.3 lib/cacchern/incrementable_sorted_set.rb
cacchern-0.0.2 lib/cacchern/incrementable_sorted_set.rb