Class: ArQueryMatchers::Queries::TableName

Inherits:
Object
  • Object
show all
Defined in:
lib/ar_query_matchers/queries/table_name.rb

Overview

An instance of this class is one of the values that could be returned from the QueryFilter#filter_map. its accepts a name of a table in the database, for example: ‘companies’.

#model_name would transform the table name (‘companies’) into the ActiveRecord model name (‘Company’). It relies on the class to be loaded in the global namespace, which should be the case if we issues a query through ActiveRecord.

Instance Method Summary collapse

Constructor Details

#initialize(table_name) ⇒ TableName

Returns a new instance of TableName.



11
12
13
# File 'lib/ar_query_matchers/queries/table_name.rb', line 11

def initialize(table_name)
  @table_name = table_name
end

Instance Method Details

#model_nameObject



15
16
17
# File 'lib/ar_query_matchers/queries/table_name.rb', line 15

def model_name
  active_record_class_for_table(@table_name)&.name
end