Class: Nemo::Examples::PersonEditor::Person
- Inherits:
-
Object
- Object
- Nemo::Examples::PersonEditor::Person
- Defined in:
- lib/nemo/examples/person_editor.rb
Constant Summary collapse
- INTERESTS =
['Art', 'Music', 'Coffee', 'Ruby']
Instance Attribute Summary collapse
-
#birthday ⇒ Object
Returns the value of attribute birthday.
-
#father ⇒ Object
Returns the value of attribute father.
-
#interests ⇒ Object
Returns the value of attribute interests.
-
#mother ⇒ Object
Returns the value of attribute mother.
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#phone_numbers ⇒ Object
Returns the value of attribute phone_numbers.
-
#sex ⇒ Object
Returns the value of attribute sex.
Instance Method Summary collapse
- #age ⇒ Object
-
#initialize ⇒ Person
constructor
A new instance of Person.
- #metaobject ⇒ Object
Constructor Details
#initialize ⇒ Person
Returns a new instance of Person.
231 232 233 234 235 |
# File 'lib/nemo/examples/person_editor.rb', line 231 def initialize @interests = ['Art', 'Music'] @password = 'abc123' @phone_numbers = Array.new end |
Instance Attribute Details
#birthday ⇒ Object
Returns the value of attribute birthday.
229 230 231 |
# File 'lib/nemo/examples/person_editor.rb', line 229 def birthday @birthday end |
#father ⇒ Object
Returns the value of attribute father.
229 230 231 |
# File 'lib/nemo/examples/person_editor.rb', line 229 def father @father end |
#interests ⇒ Object
Returns the value of attribute interests.
229 230 231 |
# File 'lib/nemo/examples/person_editor.rb', line 229 def interests @interests end |
#mother ⇒ Object
Returns the value of attribute mother.
229 230 231 |
# File 'lib/nemo/examples/person_editor.rb', line 229 def mother @mother end |
#name ⇒ Object
Returns the value of attribute name.
229 230 231 |
# File 'lib/nemo/examples/person_editor.rb', line 229 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
229 230 231 |
# File 'lib/nemo/examples/person_editor.rb', line 229 def password @password end |
#phone_numbers ⇒ Object
Returns the value of attribute phone_numbers.
229 230 231 |
# File 'lib/nemo/examples/person_editor.rb', line 229 def phone_numbers @phone_numbers end |
#sex ⇒ Object
Returns the value of attribute sex.
229 230 231 |
# File 'lib/nemo/examples/person_editor.rb', line 229 def sex @sex end |
Instance Method Details
#age ⇒ Object
237 238 239 240 |
# File 'lib/nemo/examples/person_editor.rb', line 237 def age date = (@birthday || Date.today-1) (Date.today-date).to_i/365 end |
#metaobject ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/nemo/examples/person_editor.rb', line 242 def Nemo.(self) { text :name label 'Full Name' maxlength 30 required password :password label 'Password' required date :birthday label 'Birthday' format_with { |date| date.strftime('%b %d, %Y') } required text :age label 'Age' read_only boolean :sex label 'Sex' true_item_string 'male' false_item_string 'female' single_relationship :father label 'Father' relationship_to { Wee::Session.current.domainmodel.male_persons } format_with { |each| sprintf('%s (%s)', each.name, each.[:sex].formatted_value) } nil_item_string 'unknown' single_relationship :mother label 'Mother' relationship_to { Wee::Session.current.domainmodel.female_persons } format_with { |each| sprintf('%s (%s)', each.name, each.[:sex].formatted_value) } nil_item_string 'unknown' link_action { |item| puts "==== Action was taken ====" } multiple_relationship :interests label 'Interests' relationship_to { INTERESTS } add_validation_rule { |value| value.size > 1 }. error_string('Select at least two items of interest') multiple :phone_numbers label 'Phone#s' base_class Nemo::Examples::PersonEditor::PhoneNumber format_with { |each| sprintf('%s: %s', each.type, each.number) } } end |