module Roda::RodaPlugins::Flow::RequestMethods

Public Instance Methods

resolve(*args, &block) click to toggle source
# File lib/roda/plugins/flow.rb, line 6
def resolve(*args, &block)
  on(resolve: args, &block)
end

Private Instance Methods

always(&block) click to toggle source
Calls superclass method
# File lib/roda/plugins/flow.rb, line 44
def always(&block)
  super(&get_block(&block))
end
clear_block_args() click to toggle source
# File lib/roda/plugins/flow.rb, line 62
def clear_block_args
  @block_arg = nil
  @block_method = nil
end
get_block(&block) click to toggle source
# File lib/roda/plugins/flow.rb, line 48
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
if_match(*args, &block) click to toggle source
# File lib/roda/plugins/flow.rb, line 31
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
match_call_with(call_with) click to toggle source
# File lib/roda/plugins/flow.rb, line 27
def match_call_with(call_with)
  @captures.concat(call_with)
end
match_inject(inject) click to toggle source
# File lib/roda/plugins/flow.rb, line 23
def match_inject(inject)
  @block_arg = @block_arg.call(*inject) if @block_arg
end
match_resolve(resolve) click to toggle source
# File lib/roda/plugins/flow.rb, line 12
def match_resolve(resolve)
  Array(resolve).flatten.each do |key|
    @captures << roda_class.resolve(key)
  end
end
match_to(to) click to toggle source
# File lib/roda/plugins/flow.rb, line 18
def match_to(to)
  container_key, @block_method = to.to_s.split('#')
  @block_arg = roda_class.resolve(container_key)
end