Sha256: 591c3b4701e1ec0f105359b62d94f72506ce069577c563a3a00b94ef160654f2

Contents?: true

Size: 496 Bytes

Versions: 2

Compression:

Stored size: 496 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 total(scope: :default)
      @logs[scope]&.size || 0
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chaotic_job-0.1.0 lib/chaotic_job/journal.rb
chaotic_job-0.0.1 lib/chaotic_job/journal.rb