Class: AePageObjects::ApplicationRouter::Recognizer::Rails3

Inherits:
Base
  • Object
show all
Defined in:
lib/ae_page_objects/core/application_router.rb

Direct Known Subclasses

Rails32

Instance Method Summary collapse

Methods inherited from Base

#generate_path

Instance Method Details

#recognizes?(path, url) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ae_page_objects/core/application_router.rb', line 56

def recognizes?(path, url)
  url, router = url_and_router(url)

  ["GET", "PUT", "POST", "DELETE", "PATCH"].each do |method|
    router.recognize(request_for(url, method)) do |route, matches, params|
      if route.name.to_s == path.to_s
        return true
      else
        # We break the inner loop here because only the first recognized path returned by Rails is considered,
        # which means, we only want highest prioritized route.
        break
      end
    end
  end
  false
end