Sha256: 6085a04f9d0cd0420764d7acedf7927598b8430c15e9d6f7d1a2afef83810565
Contents?: true
Size: 663 Bytes
Versions: 1
Compression:
Stored size: 663 Bytes
Contents
module ActionDispatch::Routing class Mapper def contexts(*names, &blk) names.reverse.each do |name| blk = lambda do |blk| lambda { context(name, &blk) } end.call(blk) end blk.call end def context(name, &blk) ctx = Contexts.resolve(name) path = ":#{name}" path = "(#{path})" unless ctx.respond_to?(:required?) and ctx.required? constraints ->(req) { (req.env['contexts'] ||= {})[name] = ctx } do if ctx.respond_to?(:constraints) options = { constraints: { name => ctx.constraints } } end scope(path, options, &blk) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
contexts-2.0.0 | lib/mapper.rb |