lib/tynn/matchers.rb in tynn-1.0.0.rc3 vs lib/tynn/matchers.rb in tynn-1.0.0
- old
+ new
@@ -8,11 +8,11 @@
#
# Tynn.helpers(Tynn::Matchers)
#
module Matchers
module InstanceMethods
- # Public: A catch-all matcher.
+ # Public: A catch-all matcher. Always executes the given block.
#
# Examples
#
# Tynn.define do
# authenticated? do
@@ -22,34 +22,32 @@
# default do # on true
# # ...
# end
# end
#
- # :call-seq: default(&block)
- #
def default
yield
halt(res.finish)
end
- # Public: Match if the given +key+ is present in +req.params+.
+ # Public: Executes the given block if +key+ is present in +req.params+.
#
+ # key - Any object that responds to +to_s+.
+ #
# Examples
#
# Tynn.define do
# param(:user) do |params|
# user = User.create(params)
#
# # ...
# end
#
# default do
- # res.write("missing user param")
+ # res.write("missing [user] param")
# end
# end
- #
- # :call-seq: param(key, &block)
#
def param(key)
if (v = req[key]) && !v.empty?
yield(v)