Method: MediaTypes::Scheme#initialize

Defined in:
lib/media_types/scheme.rb

#initialize(allow_empty: false, expected_type: ::Object, &block) ⇒ Scheme

Creates a new scheme

Parameters:

  • allow_empty (TrueClass, FalseClass) (defaults to: false)

    if true allows to be empty, if false raises EmptyOutputError if empty

  • expected_type (NilClass, Class) (defaults to: ::Object)

    forces the type to be this type, if given

See Also:



57
58
59
60
61
62
# File 'lib/media_types/scheme.rb', line 57

def initialize(allow_empty: false, expected_type: ::Object, &block)
  self.rules = Rules.new(allow_empty: allow_empty, expected_type: expected_type)
  self.type_attributes = {}

  instance_exec(&block) if block_given?
end