Class: Oxy::RSVP
- Inherits:
-
Object
- Object
- Oxy::RSVP
- Defined in:
- lib/oxy/middleware/rsvp.rb
Overview
RSVP middleware to transform ‘RSVP’ requests into corresponding contacts in your Google Contacts via Google People API.
Constant Summary collapse
- ELIGIBLE_FORMS_FIELDS =
The set of allowed fields. Requests that do not have fields present in this list will not be eligible to be enqueued.
['email_address', 'first_name', 'last_name']
Instance Method Summary collapse
-
#call(env) ⇒ Object
Middleware’s entry point.
-
#initialize(app, logger = $stderr) ⇒ RSVP
constructor
ctor.
Constructor Details
#initialize(app, logger = $stderr) ⇒ RSVP
ctor.
11 12 13 14 |
# File 'lib/oxy/middleware/rsvp.rb', line 11 def initialize(app, logger = $stderr) @app = app @logger = logger end |
Instance Method Details
#call(env) ⇒ Object
Middleware’s entry point
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/oxy/middleware/rsvp.rb', line 17 def call(env) # instantiate the request object req = Rack::Request.new(env) if req.path == "/rsvp" && req.post? # enqueue background processing for valid submissions only Threaded.enqueue(Subscribe, req.POST, @logger) if valid_form(req.POST) # redirect anyways [302, { "Location" => "/thank-you" }, []] else @app.call(env) end end |