Class: Renalware::Letters::Lists::Form

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/letters/lists/form.rb

Overview

Form object to help us build and parse the appropriate filters for the letters_lists controller #show action, where we display all/batch_printable letters etc. For example, when displaying batchprintable letters we need to disable the enclosures filter (setting it to No), and restrict the optionsin the letter states dropdown so only Approved or Completed letters can be batch printed. We delegate logic to an instance of a private class which is (or is a subclass of) AllLetters. If we need to add another filter type, create another sub class of AllLetters.

Defined Under Namespace

Classes: AllLetters, BatchPrintableLetters

Instance Method Summary collapse

Constructor Details

#initialize(named_filter:, params: {}) ⇒ Form

Returns a new instance of Form.



17
18
19
# File 'app/models/renalware/letters/lists/form.rb', line 17

def initialize(named_filter:, params: {})
  @handler = create_filter_specific_object_to_handle_all_requests(named_filter, params)
end

Instance Method Details

#create_filter_specific_object_to_handle_all_requests(named_filter, params) ⇒ Object



21
22
23
24
# File 'app/models/renalware/letters/lists/form.rb', line 21

def create_filter_specific_object_to_handle_all_requests(named_filter, params)
  handler_klass = "#{self.class.name}::#{named_filter.to_s.classify}Letters"
  handler_klass.constantize.new(params)
end