-
-
Save tubbo/3905548 to your computer and use it in GitHub Desktop.
UsersController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserDeliveryAgent | |
| def initialize(email) | |
| @email = email | |
| end | |
| def deliver! | |
| if @email.present? | |
| puts "Email: #{@email}" | |
| true | |
| else | |
| false | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UsersController < ApplicationController | |
| def display | |
| agent = UserDeliveryAgent.new(params[:id]) | |
| if agent.delay.deliver! | |
| render :json => { :result => "Success" } | |
| else | |
| render :json => { :result => "Failure" }, :status => 422 | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AKA UserDeliveryAgents#create