Class: Competitor
- Inherits:
-
Object
- Object
- Competitor
- Defined in:
- lib/barbershop_contestants/competitor.rb
Overview
comprises two types: quartet and chorus each has an m-to-m relationship with Contest::Quartet and Contest::Chorus, respectively
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#district ⇒ Object
Returns the value of attribute district.
-
#name ⇒ Object
Returns the value of attribute name.
-
#performances ⇒ Object
Returns the value of attribute performances.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .all ⇒ Object
- .create(arg_hash) ⇒ Object
- .fill_find_or_create(arg_hash) ⇒ Object
- .find_or_create(arg_hash) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#district ⇒ Object
Returns the value of attribute district.
5 6 7 |
# File 'lib/barbershop_contestants/competitor.rb', line 5 def district @district end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/barbershop_contestants/competitor.rb', line 5 def name @name end |
#performances ⇒ Object
Returns the value of attribute performances.
5 6 7 |
# File 'lib/barbershop_contestants/competitor.rb', line 5 def performances @performances end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/barbershop_contestants/competitor.rb', line 5 def type @type end |
Class Method Details
.all ⇒ Object
31 32 33 |
# File 'lib/barbershop_contestants/competitor.rb', line 31 def self.all @@all end |
.create(arg_hash) ⇒ Object
25 26 27 28 29 |
# File 'lib/barbershop_contestants/competitor.rb', line 25 def self.create(arg_hash) competitor = self.new(arg_hash) competitor.save competitor end |
.fill_find_or_create(arg_hash) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/barbershop_contestants/competitor.rb', line 17 def self.fill_find_or_create(arg_hash) if self.all.find { |c| c.name == arg_hash[:name] } self.fill(arg_hash) else self.create(arg_hash) end end |
.find_or_create(arg_hash) ⇒ Object
13 14 15 |
# File 'lib/barbershop_contestants/competitor.rb', line 13 def self.find_or_create(arg_hash) self.all.find { |x| x.name == arg_hash[:name] } || self.create(arg_hash) end |
Instance Method Details
#save ⇒ Object
9 10 11 |
# File 'lib/barbershop_contestants/competitor.rb', line 9 def save Competitor.all << self end |