Class: Nemo::Examples::PersonEditor::Session
- Inherits:
-
Wee::Session
- Object
- Wee::Session
- Nemo::Examples::PersonEditor::Session
- Defined in:
- lib/nemo/examples/person_editor.rb
Instance Method Summary collapse
-
#domainmodel ⇒ Object
Create a new DomainModel and populate with data.
-
#initialize ⇒ Session
constructor
Initialize the Wee session.
-
#person(hash = Hash.new) ⇒ Object
Create a new Person.
-
#phone_number(hash = Hash.new) ⇒ Object
Create a new PhoneNumber.
Constructor Details
Instance Method Details
#domainmodel ⇒ Object
Create a new DomainModel and populate with data. Define and store in a constant on creation, return existing if already defined.
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/nemo/examples/person_editor.rb', line 99 def domainmodel unless Nemo::Examples::PersonEditor.const_defined?(:Model) Nemo::Examples::PersonEditor.const_set(:Model, Nemo::Examples::PersonEditor::DomainModel.new) father = person(:name=>'Joe', :sex=>true, :birthday=>Date.new(1950,1,1)) mother = person(:name=>'Jane', :sex=>false, :birthday=>Date.new(1960,1,1)) child1 = person(:name=>'Lisa', :sex=>false, :birthday=>Date.new(1982,1,1), :father=>father, :mother=>mother) child2 = person(:name=>'Liza', :sex=>false, :birthday=>Date.new(1978,1,1), :father=>father, :mother=>mother) father.phone_numbers << phone_number(:number=>'281-328-1328', :type=>'home') child1.phone_numbers << phone_number(:number=>'132-813-2813', :type=>'work') [father, mother, child1, child2].each { |p| Nemo::Examples::PersonEditor::Model.add_person(p) } end Nemo::Examples::PersonEditor::Model end |
#person(hash = Hash.new) ⇒ Object
Create a new Person
person(:name=>'Joe', birthday=Date.new(1950,1,1))
80 81 82 83 84 |
# File 'lib/nemo/examples/person_editor.rb', line 80 def person(hash=Hash.new) obj = Nemo::Examples::PersonEditor::Person.new hash.each { |k,v| obj.send(k.to_s+'=', v) } obj end |
#phone_number(hash = Hash.new) ⇒ Object
Create a new PhoneNumber
phone_number(:type=>'home', :number=>'281-328-1328')
90 91 92 93 94 |
# File 'lib/nemo/examples/person_editor.rb', line 90 def phone_number(hash=Hash.new) obj = Nemo::Examples::PersonEditor::PhoneNumber.new hash.each { |k,v| obj.send(k.to_s+'=', v) } obj end |