module HTML::Mixin::StrongTyping

Public Instance Methods

expect(arg, allowed_types) click to toggle source
# 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