Class: AnagramSolver::Middleware
- Inherits:
-
Object
- Object
- AnagramSolver::Middleware
- Defined in:
- lib/anagram_solver/middleware.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#precomputed ⇒ Object
readonly
Returns the value of attribute precomputed.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Assigns env to @env to be used later on.
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
-
#search? ⇒ Boolean
Returns a response which is a JSON response if search_path?.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
11 12 13 14 15 |
# File 'lib/anagram_solver/middleware.rb', line 11 def initialize(app) @app = app @precomputed = "" @env = "" end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
9 10 11 |
# File 'lib/anagram_solver/middleware.rb', line 9 def app @app end |
#precomputed ⇒ Object (readonly)
Returns the value of attribute precomputed.
9 10 11 |
# File 'lib/anagram_solver/middleware.rb', line 9 def precomputed @precomputed end |
Instance Method Details
#call(env) ⇒ Object
Assigns env to @env to be used later on. If PATH_INFO matches search, it then tries to find anagrams. In not it goes down the stack.
22 23 24 25 26 |
# File 'lib/anagram_solver/middleware.rb', line 22 def call(env) @env = env uploaded_tempfile? search? || app.call(env) end |
#search? ⇒ Boolean
Returns a response which is a JSON response if search_path?
When trying to find an anagram AnagramSolver::Finder returns either anagrams found for a particular word or it returns a notice (i.e a message ) saying that No anagrams was found for that particular word.
37 38 39 |
# File 'lib/anagram_solver/middleware.rb', line 37 def search? return response if search_path? end |