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
ehbrs-tools-0.16.4 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.82.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.82.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.81.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
ehbrs-tools-0.16.3 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.55.0 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.80.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.79.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
avm-tools-0.78.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
ehbrs-tools-0.16.2 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.54.0 lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.53.0 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.77.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.52.0 lib/eac_ruby_utils/configs/base.rb
ehbrs-tools-0.16.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.51.1 lib/eac_ruby_utils/configs/base.rb
avm-tools-0.76.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.51.0 lib/eac_ruby_utils/configs/base.rb
eac_ruby_utils-0.50.0 lib/eac_ruby_utils/configs/base.rb
ehbrs-tools-0.16.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb