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.
-
#strict ⇒ Object
Returns the value of attribute strict.
Instance Method Summary collapse
- #exhaustive! ⇒ Object
-
#initialize(context = {}, exhaustive: true, strict: true, backtrace: [], 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: [], expected_key_type:) ⇒ ValidationOptions
Returns a new instance of ValidationOptions.
8 9 10 11 12 13 14 |
# File 'lib/media_types/scheme/validation_options.rb', line 8 def initialize(context = {}, exhaustive: true, strict: true, backtrace: [], expected_key_type:) self.exhaustive = exhaustive self.strict = strict self.backtrace = backtrace self.context = context self.expected_key_type = expected_key_type 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 |
#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
38 39 40 |
# File 'lib/media_types/scheme/validation_options.rb', line 38 def exhaustive! ValidationOptions.new(context, exhaustive: true, strict: strict, backtrace: backtrace, expected_key_type: expected_key_type) end |
#inspect ⇒ Object
16 17 18 |
# File 'lib/media_types/scheme/validation_options.rb', line 16 def inspect "backtrack: #{backtrace.inspect}, strict: #{strict.inspect}, exhaustive: #{exhaustive}, current_obj: #{scoped_output.to_json}" end |
#scoped_output ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/media_types/scheme/validation_options.rb', line 20 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
34 35 36 |
# File 'lib/media_types/scheme/validation_options.rb', line 34 def trace(*traces) with_backtrace(backtrace.dup.concat(traces)) end |
#with_backtrace(backtrace) ⇒ Object
30 31 32 |
# File 'lib/media_types/scheme/validation_options.rb', line 30 def with_backtrace(backtrace) ValidationOptions.new(context, exhaustive: exhaustive, strict: strict, backtrace: backtrace, expected_key_type: expected_key_type) end |