Skip to content

Commit

Permalink
make sure populator requires a limit for credit-card accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
jamis committed Nov 12, 2009
1 parent 3797771 commit d62181b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/populator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ def initialize(subscription)
@posts = []
end

def account(name, role, starting_balance, balance_date)
@accounts << { :name => name, :role => role,
def account(name, role, starting_balance, balance_date, limit=nil)
raise "you have to specify a limit for credit-card accounts" if role == "credit-card" && limit.nil?
@accounts << { :name => name, :role => role, :limit => limit,
:starting_balance => { :amount => starting_balance, :occurred_on => balance_date }}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/demo.rake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace :demo do

Populator.for(subscription) do |make|
make.account("Checking", 'checking', 1_400_00, 45.days.ago)
make.account("Mastercard", 'credit-card', -500_00, 45.days.ago)
make.account("Mastercard", 'credit-card', -500_00, 45.days.ago, 5000_00)
make.account("Savings", 'other', 750_00, 45.days.ago)

# ---------------------------------------------------
Expand Down

0 comments on commit d62181b

Please sign in to comment.