Sha256: fdcd17239dac1394236010cb903b8cab44b94face7628292f8381d9fe3699ac5

Contents?: true

Size: 903 Bytes

Versions: 3

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

require 'yaml'

class Settings
  class << self
    attr_reader :extensobr_settings
  end

  @extensobr_settings = {
    raise_for_nil: ENV['EXTENSO_RAISE_FOR_NIL'] || 'false',
    use_core_exts: ENV['EXTENSO_USE_CORE_EXTS'] || 'true'
  }

  @extensobr_settings_loaded = false

  def self.load_extensobr_settings
    return if @extensobr_settings_loaded

    if Kernel.const_defined? 'Rails'
      file_path = "#{__dir__}/config/extensobr.yml"
      if ::File.exist?(file_path)
        settings_file = ::YAML.load_file(file_path)
        @extensobr_settings[:raise_for_nil] = settings_file['extensobr_settings']['raise_for_nil'] || 'false'
        @extensobr_settings[:use_core_exts] = settings_file['extensobr_settings']['use_core_exts'] || 'true'
        @extensobr_settings_loaded = true
      else
        @extensobr_settings_loaded = false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
extensobr-1.2.2 lib/settings.rb
extensobr-1.2.1 lib/settings.rb
extensobr-1.2.0 lib/settings.rb