Sha256: b8ad398fa72380e1c72d6c895f45dfa9c5069fa7e5d65ece275f7b5b32a6935c

Contents?: true

Size: 901 Bytes

Versions: 69

Compression:

Stored size: 901 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/blank_not_blank'
require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/paths_hash'

module EacRubyUtils
  class Configs
    class Base
      enable_simple_cache

      common_constructor :data, default: [{}] do
        self.data = ::EacRubyUtils::PathsHash.new(data)
      end

      def []=(entry_key, entry_value)
        write(entry_key, entry_value)
      end

      def [](entry_key)
        read(entry_key)
      end

      def clear
        replace({})
      end

      def read(entry_key)
        return nil unless data.key?(entry_key)

        data.fetch(entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
      end

      def replace(new_data)
        self.data = ::EacRubyUtils::PathsHash.new(new_data)
      end

      def write(entry_key, entry_value)
        data[entry_key] = entry_value
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 3 rubygems

Version Path
eac_ruby_utils-0.58.1 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.88.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.87.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
ehbrs-tools-0.19.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.58.0 lib/eac_ruby_utils/configs/base.rb
ehbrs-tools-0.18.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.57.2 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.87.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.57.1 lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.57.0 lib/eac_ruby_utils/configs/base.rb
ehbrs-tools-0.17.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.86.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.85.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.56.2 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.85.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.56.1 lib/eac_ruby_utils/configs/base.rb
ehbrs-tools-0.16.5 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.84.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.56.0 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.83.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb