Created
August 12, 2012 18:49
-
-
Save vsavkin/3333670 to your computer and use it in GitHub Desktop.
Context
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 TransferringMoney | |
include Context | |
def self.transfer source_account_id, destination_account_id, amount | |
source = Account.find(source_account_id) | |
destination = Account.find(destination_account_id) | |
TransferringMoney.new(source, destination).transfer amount | |
end | |
attr_reader :source_account, :destination_account | |
def initialize source_account, destination_account | |
@source_account = source_account.extend SourceAccount | |
@destination_account = destination_account.extend DestinationAccount | |
end | |
def transfer amount | |
in_context do | |
source_account.transfer_out amount | |
end | |
end | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment