Sha256: 1905fdf542b4c836f00cc5907bae139bd41283d8f6047dcb42ce91c6c56c8074

Contents?: true

Size: 664 Bytes

Versions: 70

Compression:

Stored size: 664 Bytes

Contents

require 'rubygems'
require 'bundler/setup'

require 'mime/types'

module RubyApp

  module Mixins

    module RouteMixin

      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

70 entries across 70 versions & 1 rubygems

Version Path
RubyApp-0.0.91 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.90 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.89 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.88 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.87 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.86 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.85 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.84 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.83 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.82 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.81 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.80 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.79 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.78 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.77 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.76 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.75 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.74 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.73 lib/ruby_app/mixins/route_mixin.rb
RubyApp-0.0.72 lib/ruby_app/mixins/route_mixin.rb