Class: MediaTypes::Scheme::Links
- Inherits:
-
Object
- Object
- MediaTypes::Scheme::Links
- Defined in:
- lib/media_types/scheme/links.rb
Instance Method Summary collapse
-
#initialize ⇒ Links
constructor
A new instance of Links.
- #inspect ⇒ Object
- #link(key, allow_nil: false, optional: false, &block) ⇒ Object
- #run_fixture_validations(expect_symbol_keys, backtrace = []) ⇒ Object
- #validate!(output, options, **_opts) ⇒ Object
Constructor Details
Instance Method Details
#inspect ⇒ Object
30 31 32 |
# File 'lib/media_types/scheme/links.rb', line 30 def inspect "[Scheme::Links #{links.keys}]" end |
#link(key, allow_nil: false, optional: false, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/media_types/scheme/links.rb', line 13 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 |
#run_fixture_validations(expect_symbol_keys, backtrace = []) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/media_types/scheme/links.rb', line 34 def run_fixture_validations(expect_symbol_keys, backtrace = []) fixture_errors = @links.flat_map {|key, rule| if rule.is_a?(Scheme) begin rule.run_fixture_validations(expect_symbol_keys, backtrace.dup.append(key)) nil rescue AssertionError => e e.fixture_errors end end }.compact raise AssertionError.new(fixture_errors) unless fixture_errors.empty? end |
#validate!(output, options, **_opts) ⇒ Object
26 27 28 |
# File 'lib/media_types/scheme/links.rb', line 26 def validate!(output, , **_opts) RulesExhaustedGuard.call(output, , rules: links) end |