Sha256: 34c08ef7e4f9516194dff058ef0d6a9cb77fbf03b39b22b51d605799d3014cfe

Contents?: true

Size: 920 Bytes

Versions: 1

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

module LazyLazer
  # The key metadata collection class
  class KeyMetadataStore
    # @return [Array<Symbol>] the required properties
    attr_reader :required_properties

    def initialize
      @collection = {}
      @required_properties = []
    end

    # Add a KeyMetadata to the store.
    # @param key [Symbol] the key
    # @param meta [KeyMetadata] the key metadata
    # @return [KeyMetadata] the provided meta
    def add(key, meta)
      @collection[key] = meta
      @required_properties << key if meta.required?
      meta
    end

    # @return [Array<Symbol>] the keys in the store
    def keys
      @collection.keys
    end

    # @return [Boolean] whether the store contains the key
    def contains?(key)
      @collection.key?(key)
    end

    # @return [KeyMetadata] fetch the metadata from the store
    def get(key)
      @collection.fetch(key)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lazy_lazer-0.5.3 lib/lazy_lazer/key_metadata_store.rb