Class: TabStudentsController
- Inherits:
-
Object
- Object
- TabStudentsController
- Defined in:
- lib/controllers/tab_students_controller.rb
Instance Method Summary collapse
-
#initialize(view) ⇒ TabStudentsController
constructor
A new instance of TabStudentsController.
- #on_db_conn_error ⇒ Object
- #on_view_created ⇒ Object
- #refresh_data(page, per_page) ⇒ Object
- #show_view ⇒ Object
Constructor Details
#initialize(view) ⇒ TabStudentsController
Returns a new instance of TabStudentsController.
10 11 12 13 14 |
# File 'lib/controllers/tab_students_controller.rb', line 10 def initialize(view) @view = view @data_list = DataListStudentShort.new([]) @data_list.add_listener(@view) end |
Instance Method Details
#on_db_conn_error ⇒ Object
37 38 39 40 41 42 |
# File 'lib/controllers/tab_students_controller.rb', line 37 def on_db_conn_error api = Win32API.new('user32', 'MessageBox', ['L', 'P', 'P', 'L'], 'I') api.call(0, "No connection to DB", "Error", 0) # TODO: Возможность переключения на JSON помимо exit exit(false) end |
#on_view_created ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/controllers/tab_students_controller.rb', line 16 def on_view_created begin @student_rep = StudentRepository.new(DBSourceAdapter.new) rescue Mysql2::Error::ConnectionError on_db_conn_error end end |
#refresh_data(page, per_page) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/controllers/tab_students_controller.rb', line 28 def refresh_data(page, per_page) begin @data_list = @student_rep.paginated_short_students(page, per_page, @data_list) @view.update_student_count(@student_rep.student_count) rescue on_db_conn_error end end |
#show_view ⇒ Object
24 25 26 |
# File 'lib/controllers/tab_students_controller.rb', line 24 def show_view @view.create.show end |