Sha256: 414c07e22f9d44e63b1acaaa0df6f9e652a54697b50ec8035db1d6d1c64d7a26

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

module BellyWash
  class Resource
    include Mixins::Packer
    attr_accessor :key, :range, :at

    def initialize(key:, range:, at:)
      @key = key
      @range = range
      @at = at
    end

    def full_key
      [key, range, at.to_i].join(BellyWash.config.separator)
    end

    def increment(**values)
      packed = self.class.pack(hash: values)
      BellyWash.client.inc(key: full_key, **packed)
      {
        at => values
      }
    end

    def values
      {
        at => self.class.unpack(
          hash: BellyWash.client.get(key: full_key)
        )
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
belly_wash-0.1.1 lib/belly_wash/resource.rb