Sha256: c963cd4d62023d32c1bf3a114904011096012c79edf67f6e8ee7e662fed16e24
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
# this is taken from roda-flow plugin but it drops dependency on roda-container class Roda module RodaPlugins module Flow module RequestMethods def resolve(*args, &block) on(resolve: args, &block) end private def match_resolve(resolve) Array(resolve).flatten.each do |key| @captures << roda_class.resolve(key) end end def match_to(to) container_key, @block_method = to.to_s.split('#') @block_arg = roda_class.resolve(container_key) end def match_inject(inject) @block_arg = @block_arg.call(*inject) if @block_arg end def match_call_with(call_with) @captures.concat(call_with) end def if_match(*args, &block) path = @remaining_path # For every block, we make sure to reset captures so that # nesting matchers won't mess with each other's captures. @captures.clear return unless match_all(args) block_result(get_block(&block).call(*captures)) throw :halt, response.finish ensure @remaining_path = path end def always(&block) super(&get_block(&block)) end def get_block(&block) if block_given? block elsif @block_arg if @block_method block_arg = @block_arg.method(@block_method) else block_arg = @block_arg end clear_block_args block_arg end end def clear_block_args @block_arg = nil @block_method = nil end end end register_plugin(:flow, Flow) end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
dry-web-0.1.0 | lib/roda/plugins/flow.rb |
rodakase-0.0.1 | lib/roda/plugins/flow.rb |