Exception: DatabaseValidations::Errors::IndexNotFound
- Defined in:
- lib/database_validations/lib/errors.rb
Instance Attribute Summary collapse
-
#available_indexes ⇒ Object
readonly
Returns the value of attribute available_indexes.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#index_name ⇒ Object
readonly
Returns the value of attribute index_name.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
-
#where_clause ⇒ Object
readonly
Returns the value of attribute where_clause.
Instance Method Summary collapse
- #columns_and_where_text(columns, where) ⇒ Object
-
#initialize(columns, where_clause, index_name, available_indexes, table_name) ⇒ IndexNotFound
constructor
A new instance of IndexNotFound.
Methods inherited from Base
Constructor Details
#initialize(columns, where_clause, index_name, available_indexes, table_name) ⇒ IndexNotFound
Returns a new instance of IndexNotFound.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/database_validations/lib/errors.rb', line 12 def initialize(columns, where_clause, index_name, available_indexes, table_name) @columns = columns @where_clause = where_clause @available_indexes = available_indexes @index_name = index_name text = if index_name "No unique index found with name: \"#{index_name}\" in table \"#{table_name}\". "\ "Available indexes are: #{self.available_indexes.map(&:name)}. " else available_indexes = self.available_indexes.map { |ind| columns_and_where_text(ind.columns, ind.where) }.join(', ') "No unique index found with #{columns_and_where_text(columns, where_clause)} in table \"#{table_name}\". "\ "Available indexes are: [#{available_indexes}]. " end super text + end |
Instance Attribute Details
#available_indexes ⇒ Object (readonly)
Returns the value of attribute available_indexes.
10 11 12 |
# File 'lib/database_validations/lib/errors.rb', line 10 def available_indexes @available_indexes end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
10 11 12 |
# File 'lib/database_validations/lib/errors.rb', line 10 def columns @columns end |
#index_name ⇒ Object (readonly)
Returns the value of attribute index_name.
10 11 12 |
# File 'lib/database_validations/lib/errors.rb', line 10 def index_name @index_name end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
10 11 12 |
# File 'lib/database_validations/lib/errors.rb', line 10 def table_name @table_name end |
#where_clause ⇒ Object (readonly)
Returns the value of attribute where_clause.
10 11 12 |
# File 'lib/database_validations/lib/errors.rb', line 10 def where_clause @where_clause end |
Instance Method Details
#columns_and_where_text(columns, where) ⇒ Object
30 31 32 |
# File 'lib/database_validations/lib/errors.rb', line 30 def columns_and_where_text(columns, where) "columns: #{columns}#{" and where: #{where}" if where}" end |