Created
March 18, 2014 22:51
-
-
Save jeffdeville/9631502 to your computer and use it in GitHub Desktop.
Would something like this work?
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
| module UCP | |
| class AccountService | |
| attr_writer :cs_acct_service, :bsil_acct_service | |
| def initialize(cs_acct_service, bsil_acct_service) | |
| @cs_acct_service = cs_acct_service | |
| @bsil_acct_service = bsil_acct_service | |
| end | |
| # This is where 'workflows' can live. If they aren't sync, | |
| # then we'll invoke them w/ sidekiq or something instead. | |
| def create(composite_account) | |
| cs_acct = composite_account.to_cloudstack | |
| bsil_acct = composite_account.to_bsil | |
| begin | |
| @cs_acct_service.create cs_acct | |
| rescue | |
| # recovery? | |
| end | |
| bsil_acct.some_cs_thing = cs_acct.id | |
| begin | |
| @bsil_acct_service.create bsil_acct | |
| rescue | |
| # recovery? | |
| end | |
| true | |
| end | |
| # No abstraction? Nope. If you passed in a populated model, | |
| # have you simplified things or made them harder? | |
| def find(cs_id, bsil_id) | |
| cs_acct = @cs_acct_service.find cs_id | |
| bsil_acct = @bsil_acct_service.find bsil_id | |
| UCP::Account.new cs_acct, bsil_acct | |
| end | |
| def update(composite_account) | |
| # same as create I think | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment