Class: MediaTypes::Scheme::Attribute
- Inherits:
-
Object
- Object
- MediaTypes::Scheme::Attribute
- Defined in:
- lib/media_types/scheme/attribute.rb
Instance Method Summary collapse
-
#initialize(type, allow_nil: false) ⇒ Attribute
constructor
An attribute that expects a value of type
type
. - #inspect ⇒ Object
- #validate!(output, options, **_opts) ⇒ Object
Constructor Details
Instance Method Details
#inspect ⇒ Object
36 37 38 |
# File 'lib/media_types/scheme/attribute.rb', line 36 def inspect "[Scheme::Attribute of #{type.inspect}]" end |
#validate!(output, options, **_opts) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/media_types/scheme/attribute.rb', line 25 def validate!(output, , **_opts) return true if type === output # rubocop:disable Style/CaseEquality raise ValidationError, format( 'Expected %<type>s, got %<actual>s at [%<backtrace>s]', type: type, actual: output.inspect, backtrace: .backtrace.join('->') ) end |