Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Created April 22, 2011 22:43
Show Gist options
  • Save stevenharman/937870 to your computer and use it in GitHub Desktop.
Save stevenharman/937870 to your computer and use it in GitHub Desktop.
totally contrived example of encapsulating Rails stuff behind the AR model
class Account < ActiveRecord::Base
def invalidate!
update_attributes(:enabled => false)
end
end
# 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