Sha256: 504e1cd93b76126af3be013bb3ff782f2594bdbac2d4901bc4700eb8a06c8a69

Contents?: true

Size: 552 Bytes

Versions: 6

Compression:

Stored size: 552 Bytes

Contents

# frozen_string_literal: true

require "singleton"

module I18n
  module JS
    # @api private
    module Private
      # Caching implementation for I18n::JS.config
      #
      # @api private
      class ConfigStore
        include Singleton

        def fetch
          return @config if @config

          yield.tap do |obj|
            raise ArgumentError, "unexpected falsy object from block" unless obj

            @config = obj
          end
        end

        def flush_cache
          @config = nil
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
i18n-js-3.9.2 lib/i18n/js/private/config_store.rb
i18n-js-3.9.1 lib/i18n/js/private/config_store.rb
i18n-js-3.9.0 lib/i18n/js/private/config_store.rb
i18n-js-3.8.4 lib/i18n/js/private/config_store.rb
i18n-js-3.8.3 lib/i18n/js/private/config_store.rb
i18n-js-3.8.2 lib/i18n/js/private/config_store.rb