Class: DbdocEngine::ErrorHandlerService

Inherits:
Object
  • Object
show all
Defined in:
app/services/dbdoc_engine/error_handler_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, result, table_params = nil) ⇒ ErrorHandlerService

Returns a new instance of ErrorHandlerService.



6
7
8
9
10
# File 'app/services/dbdoc_engine/error_handler_service.rb', line 6

def initialize(table, result, table_params = nil)
  @table = table
  @result = result
  @table_params = table_params
end

Instance Attribute Details

#result ⇒ Object (readonly)

Returns the value of attribute result.



4
5
6
# File 'app/services/dbdoc_engine/error_handler_service.rb', line 4

def result
  @result
end

#table ⇒ Object (readonly)

Returns the value of attribute table.



4
5
6
# File 'app/services/dbdoc_engine/error_handler_service.rb', line 4

def table
  @table
end

#table_params ⇒ Object (readonly)

Returns the value of attribute table_params.



4
5
6
# File 'app/services/dbdoc_engine/error_handler_service.rb', line 4

def table_params
  @table_params
end

Instance Method Details

#process_errors ⇒ Object

Process errors and add them to the appropriate objects



13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/dbdoc_engine/error_handler_service.rb', line 13

def process_errors
  return unless result[:errors].present?

  result[:errors].each do |attribute, messages|
    if attribute.to_s.start_with?("db_design_dynamic_columns.")
      handle_column_error(attribute, messages)
    else
      handle_table_error(attribute, messages)
    end
  end
end