module Must

Must

Constants

Boolean

Original Type

VERSION

Public Instance Methods

must(*args, &block) click to toggle source
# File lib/must.rb, line 18
def must(*args, &block)
  if args.size > 0
    # Fast type checking
    args.each{|klass|
      return self if self.class == klass  # 1.must(Fixnum)
      return self if self       == klass  # flag.must(true, false)
      return self if klass == Boolean and (self == true or self == false)
    }

    # Or, check it in a slow but strict way
    Rule.new(self).be.kind_of(*args, &block)
  else
    Rule.new(self)
  end
end