Class: Nemo::Examples::PersonEditor::DomainModel

Inherits:
Object
  • Object
show all
Defined in:
lib/nemo/examples/person_editor.rb

Overview

Maintain a list of Person objects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDomainModel

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

#personsObject

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_personsObject



59
60
61
# File 'lib/nemo/examples/person_editor.rb', line 59

def female_persons
  @persons.find_all { |p| p.sex == false }
end

#male_personsObject



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