Created
April 22, 2011 22:43
-
-
Save stevenharman/937870 to your computer and use it in GitHub Desktop.
totally contrived example of encapsulating Rails stuff behind the AR 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 Account < ActiveRecord::Base | |
def invalidate! | |
update_attributes(:enabled => false) | |
end | |
end |
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
# assume this lives in some lib/ dir | |
class AccountStanding | |
def initialize(account) | |
@account = account | |
end | |
def enforce_good! | |
@account.invalidate! if @account.something_bad? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment