diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2015-10-06 21:10:13 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2015-10-06 21:10:13 +0200 |
commit | 5b742c1b095da2287358af0209e246fdf7452ac7 (patch) | |
tree | 90d31e8707aba879b67ad5e494271f6dff274c33 | |
parent | 5c36e7c3247c205b2bc2455f95f38fe01616498e (diff) | |
download | norsk-urskog-registrations-5b742c1b095da2287358af0209e246fdf7452ac7.tar.gz norsk-urskog-registrations-5b742c1b095da2287358af0209e246fdf7452ac7.tar.bz2 norsk-urskog-registrations-5b742c1b095da2287358af0209e246fdf7452ac7.zip |
Allow creation of bands with no params.
-rw-r--r-- | lib/band.rb | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/lib/band.rb b/lib/band.rb index ac0a9db..61efcee 100644 --- a/lib/band.rb +++ b/lib/band.rb @@ -6,27 +6,30 @@ class Band attr_reader :name, :city, :website, :label, :short_bio, :contact, :members, :songs attr_reader :errors - def initialize(params) + def initialize(params = nil) @errors = [] - @name = params['name'] - @city = params['city'] - @website = params['website'] - @label = params['label'] - @short_bio = params['shortbio'] - - @contact = Contact.new(params['contact']) - - @members = [] - if params['members'] - params['members'].each do |k, m| - @members << Member.new(m) + + if params + @name = params['name'] + @city = params['city'] + @website = params['website'] + @label = params['label'] + @short_bio = params['shortbio'] + + @contact = Contact.new(params['contact']) + + @members = [] + if params['members'] + params['members'].each do |k, m| + @members << Member.new(m) + end end - end - @songs = [] - if params['songs'] - params['songs'].each do |k, s| - @songs << Song.new(s) + @songs = [] + if params['songs'] + params['songs'].each do |k, s| + @songs << Song.new(s) + end end end end |