Class: MediaTypes::Scheme::ValidationOptions
- Inherits:
-
Object
- Object
- MediaTypes::Scheme::ValidationOptions
- Defined in:
- lib/media_types/scheme/validation_options.rb
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
Returns the value of attribute backtrace.
-
#context ⇒ Object
Returns the value of attribute context.
-
#exhaustive ⇒ Object
Returns the value of attribute exhaustive.
-
#expected_key_type ⇒ Object
Returns the value of attribute expected_key_type.
-
#loose ⇒ Object
Returns the value of attribute loose.
-
#strict ⇒ Object
Returns the value of attribute strict.
Instance Method Summary collapse
- #exhaustive! ⇒ Object
-
#initialize(context = {}, exhaustive: true, strict: true, backtrace: [], loose: false, expected_key_type:) ⇒ ValidationOptions
constructor
A new instance of ValidationOptions.
- #inspect ⇒ Object
- #scoped_output ⇒ Object
- #trace(*traces) ⇒ Object
- #with_backtrace(backtrace) ⇒ Object
Constructor Details
#initialize(context = {}, exhaustive: true, strict: true, backtrace: [], loose: false, expected_key_type:) ⇒ ValidationOptions
Returns a new instance of ValidationOptions.
8 9 10 11 12 13 14 15 |
# File 'lib/media_types/scheme/validation_options.rb', line 8 def initialize(context = {}, exhaustive: true, strict: true, backtrace: [], loose: false, expected_key_type:) self.exhaustive = exhaustive self.strict = strict self.backtrace = backtrace self.context = context self.expected_key_type = expected_key_type self.loose = loose end |
Instance Attribute Details
#backtrace ⇒ Object
Returns the value of attribute backtrace.
6 7 8 |
# File 'lib/media_types/scheme/validation_options.rb', line 6 def backtrace @backtrace end |
#context ⇒ Object
Returns the value of attribute context.
6 7 8 |
# File 'lib/media_types/scheme/validation_options.rb', line 6 def context @context end |
#exhaustive ⇒ Object
Returns the value of attribute exhaustive.
6 7 8 |
# File 'lib/media_types/scheme/validation_options.rb', line 6 def exhaustive @exhaustive end |
#expected_key_type ⇒ Object
Returns the value of attribute expected_key_type.
6 7 8 |
# File 'lib/media_types/scheme/validation_options.rb', line 6 def expected_key_type @expected_key_type end |
#loose ⇒ Object
Returns the value of attribute loose.
6 7 8 |
# File 'lib/media_types/scheme/validation_options.rb', line 6 def loose @loose end |
#strict ⇒ Object
Returns the value of attribute strict.
6 7 8 |
# File 'lib/media_types/scheme/validation_options.rb', line 6 def strict @strict end |
Instance Method Details
#exhaustive! ⇒ Object
39 40 41 |
# File 'lib/media_types/scheme/validation_options.rb', line 39 def exhaustive! ValidationOptions.new(context, exhaustive: true, strict: strict, backtrace: backtrace, expected_key_type: expected_key_type, loose: loose) end |
#inspect ⇒ Object
17 18 19 |
# File 'lib/media_types/scheme/validation_options.rb', line 17 def inspect "backtrack: #{backtrace.inspect}, strict: #{strict.inspect}, loose: #{loose}, exhaustive: #{exhaustive}, current_obj: #{scoped_output.to_json}" end |
#scoped_output ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/media_types/scheme/validation_options.rb', line 21 def scoped_output current = context backtrace.drop(1).first([0, backtrace.size - 2].max).each do |e| current = current[e] unless current.nil? end current end |
#trace(*traces) ⇒ Object
35 36 37 |
# File 'lib/media_types/scheme/validation_options.rb', line 35 def trace(*traces) with_backtrace(backtrace.dup.concat(traces)) end |
#with_backtrace(backtrace) ⇒ Object
31 32 33 |
# File 'lib/media_types/scheme/validation_options.rb', line 31 def with_backtrace(backtrace) ValidationOptions.new(context, exhaustive: exhaustive, strict: strict, backtrace: backtrace, expected_key_type: expected_key_type, loose: loose) end |