lib/coder_wally/builder.rb in coder_wally-0.1.1 vs lib/coder_wally/builder.rb in coder_wally-0.1.2

- old
+ new

@@ -4,28 +4,32 @@ # Instantiate class def initialize end # parse badges from data - def parse_badges(data) - data['badges'].map { |badge| Badge.new(badge) } if data['badges'] + def parse_badges(badges) + badges.map { |badge| create_new_badge(badge) } if badges end + # create a new badge object + def create_new_badge(badge) + Badge.new(badge) + end + # parse account information from data - def parse_accounts(data) - Account.new(data['accounts']) if data['accounts'] + def parse_accounts(accounts) + Account.new(accounts) if accounts end # parse user information from data def parse_user(data) - User.new(data['name'], data['username'], - data['location'], data['team'], data['endorsements']) + User.new(data) end # build CoderWall object from API response def build(response) - badges = parse_badges(response) - accounts = parse_accounts(response) + badges = parse_badges(response['badges']) + accounts = parse_accounts(response['accounts']) user = parse_user(response) CoderWall.new badges, user, accounts end end