Sha256: de5f864a9529afaaa27f38851438e0f66f501dc53de953339c357d50d097dac5

Contents?: true

Size: 667 Bytes

Versions: 13

Compression:

Stored size: 667 Bytes

Contents

# frozen_string_literal: true

module MediaTypes
  class Scheme
    class Links
      def initialize
        self.links = {}
      end

      def link(key, allow_nil: false, &block)
        scheme = Scheme.new
        scheme.attribute :href, String, allow_nil: allow_nil
        scheme.instance_exec(&block) if block_given?

        links[key] = scheme
      end

      def validate!(output, options, **_opts)
        links.all? do |key, value|
          value.validate!(
            output[key],
            options.trace(key).exhaustive!
          )
        end
      end

      private

      attr_accessor :links
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
media_types-0.4.0 lib/media_types/scheme/links.rb
media_types-0.3.0 lib/media_types/scheme/links.rb
media_types-0.2.6 lib/media_types/scheme/links.rb
media_types-0.2.5 lib/media_types/scheme/links.rb
media_types-0.2.4 lib/media_types/scheme/links.rb
media_types-0.2.3 lib/media_types/scheme/links.rb
media_types-0.2.2 lib/media_types/scheme/links.rb
media_types-0.2.1 lib/media_types/scheme/links.rb
media_types-0.2.0 lib/media_types/scheme/links.rb
media_types-0.1.3 lib/media_types/scheme/links.rb
media_types-0.1.2 lib/media_types/scheme/links.rb
media_types-0.1.1 lib/media_types/scheme/links.rb
media_types-0.1.0 lib/media_types/scheme/links.rb