Module: Must
- Defined in:
- lib/must.rb,
lib/must/rule.rb,
lib/must/differ.rb,
lib/must/version.rb,
lib/must/struct_info.rb
Overview
Must
Defined Under Namespace
Classes: ClassMismatch, Differ, Invalid, Rule, StructInfo, StructMismatch, ValueMismatch
Constant Summary collapse
- Boolean =
Original Type
Class.new
- VERSION =
"0.3.3"
Instance Method Summary collapse
Instance Method Details
#must(*args, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |