Module: HTML::Mixin::StrongTyping

Overview

The StrongTyping module is a pure Ruby replacement for the strongtyping gem.

Instance Method Summary collapse

Instance Method Details

#expect(arg, allowed_types) ⇒ Object

Raises:



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

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

  # Defined in table.rb
  raise ArgumentTypeError, "#{arg} must be of type #{allowed_types}"
end