Sha256: 56c24330bb366f8b13090320bf1ff526c3e2bdcc407cbd5517659358e770cab6

Contents?: true

Size: 667 Bytes

Versions: 13

Compression:

Stored size: 667 Bytes

Contents

# frozen_string_literal: true

require_relative 'hash_informable'

module MadFlatter
  # Provides methods to load and return information about a given hash.
  module HashLoadable
    include HashInformable

    private

    def load_hash(hash, options)
      raise ArgumentError, "Argument hash is not a Hash (#{hash.class})" unless hash.is_a? Hash

      return {} if hash.blank?

      hash_info = load_hash_info(hash: hash, namespace: options.namespace)
      return hash_info if options.metadata?

      strip_metadata(hash_info)
    end

    def strip_metadata(hash)
      hash.transform_values do |metadata|
        metadata[:value]
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mad_flatter-3.0.8 lib/mad_flatter/hash_loadable.rb
mad_flatter-3.0.7 lib/mad_flatter/hash_loadable.rb
mad_flatter-3.0.6 lib/mad_flatter/hash_loadable.rb
mad_flatter-3.0.5 lib/mad_flatter/hash_loadable.rb
mad_flatter-3.0.4 lib/mad_flatter/hash_loadable.rb
mad_flatter-3.0.3 lib/mad_flatter/hash_loadable.rb
mad_flatter-3.0.2 lib/mad_flatter/hash_loadable.rb
mad_flatter-3.0.1 lib/mad_flatter/hash_loadable.rb
mad_flatter-3.0.0 lib/mad_flatter/hash_loadable.rb
mad_flatter-2.1.0 lib/mad_flatter/hash_loadable.rb
mad_flatter-2.0.0 lib/mad_flatter/hash_loadable.rb
mad_flatter-1.0.1.pre.beta lib/mad_flatter/hash_loadable.rb
mad_flatter-1.0.0.pre.beta lib/mad_flatter/hash_loadable.rb