Class: MediaTypes::Scheme::OutputTypeGuard
- Inherits:
-
Object
- Object
- MediaTypes::Scheme::OutputTypeGuard
- Defined in:
- lib/media_types/scheme/output_type_guard.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(output, options, rules:) ⇒ OutputTypeGuard
constructor
A new instance of OutputTypeGuard.
Constructor Details
#initialize(output, options, rules:) ⇒ OutputTypeGuard
Returns a new instance of OutputTypeGuard.
14 15 16 17 18 |
# File 'lib/media_types/scheme/output_type_guard.rb', line 14 def initialize(output, , rules:) self.output = output self. = self.expected_type = rules.expected_type end |
Class Method Details
.call(*args, **opts, &block) ⇒ Object
9 10 11 |
# File 'lib/media_types/scheme/output_type_guard.rb', line 9 def call(*args, **opts, &block) new(*args, **opts).call(&block) end |
Instance Method Details
#call ⇒ Object
20 21 22 23 |
# File 'lib/media_types/scheme/output_type_guard.rb', line 20 def call return unless expected_type && !(expected_type === output) # rubocop:disable Style/CaseEquality raise_type_error!(type: output.class, backtrace: .backtrace) end |