-
-
Save yock/a7f55af369dfb8716e96 to your computer and use it in GitHub Desktop.
Refactored user model
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 User < ActiveRecord::Base | |
## Omitting Rails stuff... | |
attr_accessor :service, :cc_token | |
def pay(amount) | |
service.pay(amount, external_id: self.external_id) | |
end | |
def register | |
self.external_id = service.register(self.cc_token, name: self.name, email: self.email) | |
self.save | |
end | |
def service | |
@service ||= GatewayService | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment