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
avm-tools-0.98.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.97.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.96.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.63.0 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.95.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.62.1 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.94.3 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.62.0 lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.61.0 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.94.2 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.60.0 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.94.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.59.0 lib/eac_ruby_utils/configs/base.rb
ehbrs-tools-0.20.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.94.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.93.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.92.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.91.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.90.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.89.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb