Sha256: e92d53a87d13655a47022db4f5d2aee3f3714f278cd99adcb72deb117f1b10cc

Contents?: true

Size: 707 Bytes

Versions: 3

Compression:

Stored size: 707 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.5.0
class Qonfig::Loaders::JSON < Qonfig::Loaders::Basic
  class << self
    # @param data [String]
    # @return [Object]
    #
    # @raise [Qonfig::JSONLoaderParseError]
    #
    # @api private
    # @since 0.5.0
    # @version 0.26.0
    def load(data)
      ::JSON.parse(ERB.new(data).result, max_nesting: false, allow_nan: true)
    rescue ::JSON::ParserError => error
      raise(Qonfig::JSONLoaderParseError.new(error.message).tap do |exception|
        exception.set_backtrace(error.backtrace)
      end)
    end

    # @return [Object]
    #
    # @api private
    # @since 0.5.0
    def load_empty_data
      load('{}')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qonfig-0.28.0 lib/qonfig/loaders/json.rb
qonfig-0.27.0 lib/qonfig/loaders/json.rb
qonfig-0.26.0 lib/qonfig/loaders/json.rb