Sha256: 0df938ed4778b183b1170c66e971e0a9ad912936f943a916baff840ebb974e54

Contents?: true

Size: 1.15 KB

Versions: 10

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require "zeitwerk"
loader = Zeitwerk::Loader.for_gem
loader.ignore("#{__dir__}/meibo/errors.rb")
loader.ignore("#{__dir__}/meibo/factory_bot")
loader.setup

require_relative "meibo/version"
require_relative "meibo/errors"

module Meibo
  CSV_ENCODING = "UTF-8"
  ENUM_EXT_PATTERN = /\Aext:[a-zA-Z0-9.\-_]+\z/.freeze

  class << self
    attr_accessor :default_profile

    def current_profile
      thread_local_data[:current_profile] || default_profile
    end

    def current_roster
      thread_local_data[:roster]
    end

    def with_profile(default_profile)
      orig_default_profile = thread_local_data[:current_profile]
      thread_local_data[:current_profile] = default_profile
      yield
    ensure
      thread_local_data[:current_profile] = orig_default_profile
    end

    def with_roster(roster)
      orig_roster = thread_local_data[:roster]
      thread_local_data[:roster] = roster
      yield
    ensure
      thread_local_data[:roster] = orig_roster
    end

    private

    def thread_local_data
      Thread.current[:__meibo] ||= {}
    end
  end
end

loader.eager_load

Meibo.default_profile = Meibo::Profiles["v1.2"]

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
meibo-0.27.1 lib/meibo.rb
meibo-0.27.0 lib/meibo.rb
meibo-0.26.0 lib/meibo.rb
meibo-0.25.3 lib/meibo.rb
meibo-0.25.2 lib/meibo.rb
meibo-0.25.1 lib/meibo.rb
meibo-0.25.0 lib/meibo.rb
meibo-0.24.0 lib/meibo.rb
meibo-0.23.0 lib/meibo.rb
meibo-0.22.0 lib/meibo.rb