Sha256: b614e9a41c405bf4d3b6b5f0ec897b7982a15881386fb7f2d564797ec7559019
Contents?: true
Size: 870 Bytes
Versions: 10
Compression:
Stored size: 870 Bytes
Contents
# frozen_string_literal: true require 'media_types/scheme/rules' require 'media_types/scheme/rules_exhausted_guard' module MediaTypes class Scheme class Links def initialize self.links = Rules.new(allow_empty: false, expected_type: ::Hash) end def link(key, allow_nil: false, optional: false, &block) links.add( key, Scheme.new do attribute :href, String, allow_nil: allow_nil instance_exec(&block) if block_given? end, optional: optional ) self end def validate!(output, options, **_opts) RulesExhaustedGuard.call(output, options, rules: links) end def inspect "[Scheme::Links #{links.keys}]" end private attr_accessor :links end end end
Version data entries
10 entries across 10 versions & 1 rubygems