Sha256: 962bcf5a1c00ae5c55025158c86391f3c08d07655de870f0acd732ffe4b48e32

Contents?: true

Size: 604 Bytes

Versions: 3

Compression:

Stored size: 604 Bytes

Contents

require 'jellyfish'



module Jellyfish
  module MultiActions
    def call env
      @env = env
      dispatch.inject(nil){ |_, route_block| block_call(*route_block) }
    end

    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?
        halt(Jellyfish::NotFound.new)
      else
        acts
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jellyfish-0.9.2 lib/jellyfish/multi_actions.rb
jellyfish-0.9.1 lib/jellyfish/multi_actions.rb
jellyfish-0.9.0 lib/jellyfish/multi_actions.rb