Last active
April 15, 2019 10:15
-
-
Save fathur/9e74129fc8c3f24ac6390443d48d999b to your computer and use it in GitHub Desktop.
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 MidwifeRegistrationService | |
| def initialize(options = {}) | |
| @params = options[:params] | |
| end | |
| def call | |
| create_user | |
| send_sms | |
| self | |
| end | |
| def call! | |
| validate | |
| call | |
| end | |
| def validate | |
| end | |
| def create_user | |
| @data = Midwife.create() | |
| @data.create_prop() | |
| end | |
| def send_sms | |
| SmsOtpBackground.enqueue @data.id | |
| 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 MotherRegistrationService | |
| def initialize(options = {}) | |
| @params = options[:params] | |
| end | |
| def call | |
| create_user | |
| send_email | |
| self | |
| end | |
| def call! | |
| validate | |
| call | |
| end | |
| def validate | |
| end | |
| def create_user | |
| @data = Mother.create() | |
| @data.create_prop() | |
| end | |
| def send_email | |
| EmailOtpBackground.enqueue @data.id | |
| 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 RegistrationService | |
| def initialize(options = {}) | |
| @headers = options[:headers] | |
| @params = options[:params] | |
| end | |
| def call | |
| role = @headers['X-Product'].to_sym | |
| class_name = (role.to_s + 'RegistrationService').camelize | |
| class_name.constantize.call params: @params | |
| end | |
| def call! | |
| validate | |
| call | |
| end | |
| def validate | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment