Class: MediaTypes::Scheme::OutputEmptyGuard

Inherits:
Object
  • Object
show all
Defined in:
lib/media_types/scheme/output_empty_guard.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output, options, rules:) ⇒ OutputEmptyGuard

Returns a new instance of OutputEmptyGuard.



15
16
17
18
19
# File 'lib/media_types/scheme/output_empty_guard.rb', line 15

def initialize(output, options, rules:)
  self.output = output
  self.options = options
  self.rules = rules
end

Class Method Details

.call(*args, **opts, &block) ⇒ Object



10
11
12
# File 'lib/media_types/scheme/output_empty_guard.rb', line 10

def call(*args, **opts, &block)
  new(*args, **opts).call(&block)
end

Instance Method Details

#callObject



21
22
23
24
25
# File 'lib/media_types/scheme/output_empty_guard.rb', line 21

def call
  return unless MediaTypes::Object.new(output).empty?
  throw(:end, true) if allow_empty?
  raise_empty!(backtrace: options.backtrace, found: options.scoped_output)
end