Sha256: 877c78c760c5521a938b817e4ffc278784ec37bf6f821321eb3e413a20c599fe

Contents?: true

Size: 345 Bytes

Versions: 3

Compression:

Stored size: 345 Bytes

Contents

require 'minuteman/model'

module Minuteman
  class Counter < Minuteman::Model
    class User < Counter
      attribute :user_id

      def key
        "#{super}:#{user_id}"
      end
    end

    def incr
      Minuteman.config.redis.call("INCR", key)
    end

    def count
      Minuteman.config.redis.call("GET", key).to_i
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
minuteman-3.0.0 lib/minuteman/counter.rb
minuteman-2.0.0 lib/minuteman/counter.rb
minuteman-2.0.0.pre lib/minuteman/counter.rb