Sha256: 3ffc6b944abce4ccd066de9aad7869c9091aa203c9b6a15fe35e4b975a8ad6c2

Contents?: true

Size: 558 Bytes

Versions: 3

Compression:

Stored size: 558 Bytes

Contents

# frozen_string_literal: true

# Journal.log
# Journal.log(thing, scope: :special)
# Journal.total
# Journal.total(scope: :special)
# Journal.all

module ChaoticJob
  module Journal
    extend self

    def reset!
      @logs = {}
    end

    def log(item = 1, scope: :default)
      @logs ||= {}
      @logs[scope] ||= []
      @logs[scope] << item
    end

    def size(scope: :default)
      @logs[scope]&.size || 0
    end

    def entries(scope: :default)
      @logs[scope]
    end

    def top(scope: :default)
      entries&.first
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chaotic_job-0.3.0 lib/chaotic_job/journal.rb
chaotic_job-0.2.0 lib/chaotic_job/journal.rb
chaotic_job-0.1.1 lib/chaotic_job/journal.rb