Class: StudentContactFormController
- Inherits:
-
Object
- Object
- StudentContactFormController
- Defined in:
- lib/source/student_contact_form_controller.rb
Instance Method Summary collapse
-
#initialize(parent_controller, existing_student_id) ⇒ StudentContactFormController
constructor
A new instance of StudentContactFormController.
- #on_view_created ⇒ Object
- #process_fields(fields) ⇒ Object
- #set_fields(student) ⇒ Object
- #view=(view) ⇒ Object
Constructor Details
#initialize(parent_controller, existing_student_id) ⇒ StudentContactFormController
Returns a new instance of StudentContactFormController.
2 3 4 5 6 |
# File 'lib/source/student_contact_form_controller.rb', line 2 def initialize(parent_controller, existing_student_id) @parent_controller = parent_controller @existing_student_id = existing_student_id LoggerHolder.instance.debug('StudentCreateFormController: initialized') end |
Instance Method Details
#on_view_created ⇒ Object
13 14 15 16 17 18 |
# File 'lib/source/student_contact_form_controller.rb', line 13 def on_view_created @student_list = StudentList.new(StudentListDBAdapter.new) @existing_student = @student_list.student_by_id(@existing_student_id) @view.make_readonly(:first_name,:last_name,:paternal_name, :git) set_fields(@existing_student) end |
#process_fields(fields) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/source/student_contact_form_controller.rb', line 33 def process_fields(fields) new_student = Student.new(**fields) @student_list.replace_student(@existing_student_id, new_student) @view.close LoggerHolder.instance.debug('StudentCreateFormController: add student') end |
#set_fields(student) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/source/student_contact_form_controller.rb', line 20 def set_fields(student) student = student puts student @view.set_value(:last_name, student.last_name) @view.set_value(:first_name, student.first_name) @view.set_value(:paternal_name, student.paternal_name) @view.set_value(:git, student.git) @view.set_value(:telegram, student.telegram) @view.set_value(:email, student.email) @view.set_value(:phone, student.phone) end |
#view=(view) ⇒ Object
8 9 10 11 |
# File 'lib/source/student_contact_form_controller.rb', line 8 def view=(view) @view = view LoggerHolder.instance.debug('StudentCreateFormController: setter view') end |