Class: SecureEscrow::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/secure_escrow/middleware.rb

Defined Under Namespace

Classes: Presenter

Instance Method Summary collapse

Constructor Details

#initialize(next_app, rails_app, config) ⇒ Middleware

Returns a new instance of Middleware.



33
34
35
36
37
38
# File 'lib/secure_escrow/middleware.rb', line 33

def initialize next_app, rails_app, config
  @next_app   = next_app
  @rails_app  = rails_app
  @config     = config
  @store      = config[:store]
end

Instance Method Details

#call(env) ⇒ Object



40
41
42
# File 'lib/secure_escrow/middleware.rb', line 40

def call env
  handle_presenter presenter(env)
end

#handle_presenter(e) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/secure_escrow/middleware.rb', line 48

def handle_presenter e
  if e.serve_response_from_escrow?
    e.serve_response_from_escrow!
  elsif e.response_is_redirect?
    e.redirect_to_response!
  elsif e.store_response_in_escrow?
    e.store_response_in_escrow_and_redirect!
  else
    e.serve_response_from_application!
  end
end

#presenter(env) ⇒ Object



44
45
46
# File 'lib/secure_escrow/middleware.rb', line 44

def presenter env
  Presenter.new @next_app, @rails_app, @config, env
end