Class: Nemo::Examples::PersonEditor::DomainModel
- Inherits:
-
Object
- Object
- Nemo::Examples::PersonEditor::DomainModel
- Defined in:
- lib/nemo/examples/person_editor.rb
Overview
Maintain a list of Person objects
Instance Attribute Summary collapse
-
#persons ⇒ Object
Returns the value of attribute persons.
Instance Method Summary collapse
- #add_person(person) ⇒ Object
- #female_persons ⇒ Object
-
#initialize ⇒ DomainModel
constructor
A new instance of DomainModel.
- #male_persons ⇒ Object
- #remove_person(person) ⇒ Object
Constructor Details
#initialize ⇒ DomainModel
Returns a new instance of DomainModel.
43 44 45 |
# File 'lib/nemo/examples/person_editor.rb', line 43 def initialize @persons = Array.new end |
Instance Attribute Details
#persons ⇒ Object
Returns the value of attribute persons.
41 42 43 |
# File 'lib/nemo/examples/person_editor.rb', line 41 def persons @persons end |
Instance Method Details
#add_person(person) ⇒ Object
47 48 49 |
# File 'lib/nemo/examples/person_editor.rb', line 47 def add_person(person) @persons << person end |
#female_persons ⇒ Object
59 60 61 |
# File 'lib/nemo/examples/person_editor.rb', line 59 def female_persons @persons.find_all { |p| p.sex == false } end |
#male_persons ⇒ Object
55 56 57 |
# File 'lib/nemo/examples/person_editor.rb', line 55 def male_persons @persons.find_all { |p| p.sex == true } end |
#remove_person(person) ⇒ Object
51 52 53 |
# File 'lib/nemo/examples/person_editor.rb', line 51 def remove_person(person) @persons.delete(person) end |