lib/y_petri/place/guarded.rb in y_petri-2.3.3 vs lib/y_petri/place/guarded.rb in y_petri-2.3.4

- old
+ new

@@ -3,24 +3,24 @@ # Support of places' marking guards. # module YPetri::Place::Guarded # Expects a guard assertion in natural language, and a guard block. Guard # block is a unary block that validates marking. A validation fails when: - # + # # 1. The block returns _false_. # 2. The block raises +YPetri::GuardError+. - # + # # In all other cases, including when the block returns _nil_ (beware!), # the marking is considered valid! Inside the block, +#fail+ keyword is # redefined so that it can (and must) be called without arguments, and it # raises an appropriately worded +GuardError+. (Other exceptions can still # be raised using +#raise+ keyword.) Practical example: - # + # # guard "should be a number" do |m| fail unless m.is_a? Numeric end - # + # # Then <code>guard! :foobar</code> raises +GuardError+ with a message "Marking # foobar:Symbol should be a number!" - # + # # Finally, this method is overloaded in such way, that if no block is # given to it, it acts as an alias of +#common_guard_closure+ method. # def guard *args, &block if block then