Created
December 5, 2018 00:48
-
-
Save packrat386/39efdc7ea3f448dc00aef177fdb12fd6 to your computer and use it in GitHub Desktop.
What is green may not always be grue
This file contains 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 CustomerNotifier | |
def initialize(mail_server, templates) | |
@mail_server = mail_server | |
@templates = templates | |
end | |
def confirm_order(customer, data) | |
@mail_server.send_mail(customer.email_address, @templates[:confirm_order].render(data)) | |
end | |
def password_reset(customer, data) | |
@mail_server.send_mail(customer.email_address, @templates[:password_reset].render(data)) | |
end | |
end |
This file contains 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 CustomerNotifier | |
def initialize(mail_server, templates) | |
@mail_server = mail_server | |
@templates = templates | |
end | |
def send_template(template, customer, data) | |
@mail_server.send_mail(customer.email_address, @templates[template].render(data)) | |
end | |
end |
This file contains 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 CustomerNotifier | |
def initialize(mail_server, templates) | |
@mail_server = mail_server | |
@templates = templates | |
end | |
ASYNC_TEMPLATES = %i[promo_code] | |
def send_template(template, customer, data) | |
if ASYNC_TEMPLATES.include?(template) | |
AsyncEmail.create!(customer: customer, data: data) | |
else | |
@mail_server.send_mail(customer.email_address, @templates[template].render(data)) | |
end | |
end | |
end |
This file contains 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 GemRegistrar | |
def initialize(grs_client) | |
@grs_client = grs_client | |
end | |
def register_emerald | |
id = @grs_client.register_gem( | |
type: 'emerald', | |
color: 'green' | |
) | |
Gemstone.create!(registration_id: id, type: 'emerald', color: 'green') | |
end | |
def register_ruby | |
id = @grs_client.register_gem( | |
type: 'ruby', | |
color: 'red' | |
) | |
Gemstone.create!(registration_id: id, type: 'ruby', color: 'red') | |
end | |
end |
This file contains 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 GemRegistrar | |
def initialize(grs_client) | |
@grs_client = grs_client | |
end | |
def register_gem(type, color) | |
id = @grs_client.register_gem( | |
type: type, | |
color: color | |
) | |
Gemstone.create!(registration_id: id, type: type, color: color) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment