Skip to content

Commit

Permalink
Remove Player.all and Game.all
Browse files Browse the repository at this point in the history
Though these may have been convenient in simple examples, they stored
all Objects initialized permanently, so was unfit for real applications.
  • Loading branch information
jhawthorn committed Jun 7, 2015
1 parent 63d0505 commit f97c835
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
12 changes: 0 additions & 12 deletions lib/elo/helper.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
module Elo
module Helper
def self.included(base)
base.extend ClassMethods
end

# Every object can be initialized with a hash,
# almost, but not quite, entirely unlike ActiveRecord.
def initialize(attributes = {})
attributes.each do |key, value|
instance_variable_set("@#{key}", value)
end
self.class.all << self
end

module ClassMethods
# Provides a list of all instantiated objects of the class.
def all
@all ||= []
end
end
end
end
3 changes: 0 additions & 3 deletions spec/elo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
expect(bob).to be_starter
expect(bob.games_played).to eq(8)
expect(bob.games).to eq([game1, game2, game3, game4, game5, game6, game7, game8])

expect(Elo::Player.all).to eq([bob, jane])
expect(Elo::Game.all).to eq([game1, game2, game3, game4, game5, game6, game7, game8])
end

describe 'Configuration' do
Expand Down

0 comments on commit f97c835

Please sign in to comment.