diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2015-10-10 14:24:55 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2015-10-10 14:24:55 +0200 |
commit | dce607a72ecc2cc5415ee025452173dc927e1b94 (patch) | |
tree | 8966a95bab6653fa556524c3c21bae13c7d31720 | |
parent | f8cd616b1e7a4565c31579ab17951901902b4453 (diff) | |
download | norsk-urskog-registrations-dce607a72ecc2cc5415ee025452173dc927e1b94.tar.gz norsk-urskog-registrations-dce607a72ecc2cc5415ee025452173dc927e1b94.tar.bz2 norsk-urskog-registrations-dce607a72ecc2cc5415ee025452173dc927e1b94.zip |
Fix init of empty band.
-rw-r--r-- | lib/band.rb | 5 | ||||
-rw-r--r-- | lib/contact.rb | 12 |
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/band.rb b/lib/band.rb index 61efcee..760274b 100644 --- a/lib/band.rb +++ b/lib/band.rb @@ -8,6 +8,9 @@ class Band def initialize(params = nil) @errors = [] + @contact = Contact.new + @members = [] + @songs = [] if params @name = params['name'] @@ -18,14 +21,12 @@ class Band @contact = Contact.new(params['contact']) - @members = [] if params['members'] params['members'].each do |k, m| @members << Member.new(m) end end - @songs = [] if params['songs'] params['songs'].each do |k, s| @songs << Song.new(s) diff --git a/lib/contact.rb b/lib/contact.rb index 1e6ba4b..0d87012 100644 --- a/lib/contact.rb +++ b/lib/contact.rb @@ -1,10 +1,12 @@ class Contact attr_reader :name, :addr, :phone, :email - def initialize(params) - @name = params['name'] - @addr = params['addr'] - @phone = params['phone'] - @email = params['email'] + def initialize(params = nil) + if params + @name = params['name'] + @addr = params['addr'] + @phone = params['phone'] + @email = params['email'] + end end end |