Sha256: 7005542936b31b51428d7682c08a176cccc8fb6e9464a95ce47775a78d8630e1

Contents?: true

Size: 675 Bytes

Versions: 3

Compression:

Stored size: 675 Bytes

Contents

require 'rubygems'
require 'bundler/setup'

require 'mime/types'

module RubyApp
  
  module Mixins
  
    module Route

      GET = 'GET'
      POST = 'POST'

      def route(method, pattern, &block)
        self.routes << { :method => method, :pattern => pattern, :block => block }
      end
      
      def do_route(method, path)
        self.routes.each do |route|
          if method == route[:method] and path =~ route[:pattern]
            return route[:block].call([method].concat($~.to_a))
          end
        end
      end
      
      def routes
        @_routes ||= []
      end

      def clear_routes
        self.routes.clear
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
RubyApp-0.0.8 lib/ruby_app/mixins/route.rb
RubyApp-0.0.7 lib/ruby_app/mixins/route.rb
RubyApp-0.0.6 lib/ruby_app/mixins/route.rb