Sha256: e2b139a3203a5fdf177d518a2b5caf76d351cf5c18f6d91d394cdf7c56193875

Contents?: true

Size: 753 Bytes

Versions: 3

Compression:

Stored size: 753 Bytes

Contents

module Baurets
  module Optionsful
    module Introspections

      def self.do_the_matches(path_info)
        routes = Rails.application.routes.routes if defined? Rails # Rails major = 3
        routes.reject!{ |r| r.path == "/rails/info/properties" } # skip the route if it's internal info route
        allow = ""
        routes.each do |route|
          if path_info =~ route.conditions[:path_info] 
            if route.verb
              allow += (route.verb.to_s.upcase + "|") unless allow.include?(route.verb.to_s.upcase)
            else
              # TODO - return 'ANY' doesn't sound ANY good ;p
              allow = "GET"
            end
          end
        end
        allow = allow.split("|").join(", ") 
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
optionsful-0.3.2 lib/baurets/optionsful/introspections.rb
optionsful-0.3.1 lib/baurets/optionsful/introspections.rb
optionsful-0.3.0 lib/baurets/optionsful/introspections.rb