lib/must/rule.rb in maiha-must-0.1 vs lib/must/rule.rb in maiha-must-0.2
- old
+ new
@@ -1,5 +1,7 @@
+require 'set'
+
module Must
class Rule
attr_reader :object
def initialize(object)
@@ -22,11 +24,11 @@
valid?(object == args.shift, &block)
end
end
def empty(&block)
- valid?(object.blank?, &block)
+ valid?(object.empty?, &block)
end
def blank(&block)
valid?(object.blank?, &block)
end
@@ -36,10 +38,10 @@
be(nil, &block)
end
def kind_of(*targets)
valid?(targets.any?{|klass| object.is_a? klass}) {
- target = targets.map(&:name).join('/')
+ target = targets.map{|i| i.name}.join('/')
raise Invalid, "expected #{target} but got #{object.class}"
}
end
def one_of(target, &block)