Sha256: c54d388c44db038976046ede5a402ae45417adc398af8cbe30d090db0d0218d7
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
class Tynn # Public: Adds extra matchers to Tynn. # # Examples # # require "tynn" # require "tynn/matchers" # # Tynn.helpers(Tynn::Matchers) # module Matchers module InstanceMethods # Public: A catch-all matcher. Always executes the given block. # # Examples # # Tynn.define do # authenticated? do # # ... # end # # default do # on true # # ... # end # end # def default yield halt(res.finish) end # 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") # end # end # def param(key) if (v = req[key]) && !v.empty? yield(v) halt(res.finish) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tynn-1.0.0 | lib/tynn/matchers.rb |