Sha256: 5837d8be8bc43cb0732b13cca03bbfb4b2e94532a5657e447d9de82d91bceeb0

Contents?: true

Size: 931 Bytes

Versions: 3

Compression:

Stored size: 931 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.2.0
# rubocop:disable Style/StaticClass
class Qonfig::Loaders::Basic
  class << self
    # @param data [String]
    # @return [void]
    #
    # @api private
    # @since 0.5.0
    def load(data)
      nil # NOTE: consciously return nil (for clarity)
    end

    # @return [void]
    #
    # @api private
    # @since 0.5.0
    def load_empty_data
      nil # NOTE: consciously return nil (for clarity)
    end

    # @param file_path [String, Pathname]
    # @option fail_on_unexist [Boolean]
    # @return [Object]
    #
    # @raise [Qonfig::FileNotFoundError]
    #
    # @api private
    # @since 0.5.0
    def load_file(file_path, fail_on_unexist: true)
      load(::File.read(file_path))
    rescue Errno::ENOENT => error
      fail_on_unexist ? (raise Qonfig::FileNotFoundError, error.message) : load_empty_data
    end
  end
end
# rubocop:enable Style/StaticClass

Version data entries

3 entries across 3 versions & 1 rubygems

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