Created
July 8, 2011 06:59
-
-
Save joecannatti/1071280 to your computer and use it in GitHub Desktop.
conflicting prince
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 SessionsController | |
def create | |
user = log_in_user | |
user.send_current_notifications! | |
end | |
def log_in_user | |
account = #sign in with params | |
UserFactory.user_for_account(account) | |
end | |
end | |
class Account < ActiveRecord::Base | |
end | |
class User | |
attr_accessor :account | |
def initialize(accout) | |
self.account = account | |
end | |
def has_access? | |
true | |
end | |
def send_current_notifications! | |
#blank here, but probably delegating to something | |
#else in a more complex example | |
end | |
end | |
class DisabledUser < User | |
def has_access? | |
false | |
end | |
def send_current_notifications! | |
account.send_disabled_notification! | |
end | |
end | |
class UserFactory | |
def self.user_for_account(account) | |
class_for_account(account).send(:new, account) | |
end | |
private | |
def self.class_for_account(account) | |
account.all_cards_invalid? ? DisabledUser : User | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment