Module: HTML::Mixin::StrongTyping

Defined in:
lib/html/mixin/strongtyping.rb

Defined Under Namespace

Classes: ArgumentTypeError

Instance Method Summary collapse

Instance Method Details

#expect(arg, allowed_types) ⇒ Object

Raises:



8
9
10
11
12
13
14
# File 'lib/html/mixin/strongtyping.rb', line 8

def expect(arg, allowed_types)
  return true if Array(allowed_types).any? do |klass|
    arg.kind_of?(klass)
  end

  raise ArgumentTypeError.new("#{arg} must be of type #{allowed_types}")
end