Module: Jellyfish::MultiActions
- Included in:
- Sinatra
- Defined in:
- lib/jellyfish/multi_actions.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 |
# File 'lib/jellyfish/multi_actions.rb', line 8 def call env @env = env dispatch.inject(nil){ |_, route_block| block_call(*route_block) } end |
#dispatch ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jellyfish/multi_actions.rb', line 13 def dispatch acts = actions.map{ |(route, block)| case route when String [route, block] if route == path_info else#Regexp, using else allows you to use custom matcher match = route.match(path_info) [match, block] if match end }.compact if acts.empty? action_missing else acts end end |