Class: RailsVisualizer::Schema::IndexInspector
- Inherits:
-
Object
- Object
- RailsVisualizer::Schema::IndexInspector
- Defined in:
- lib/rails_visualizer/schema/index_inspector.rb
Instance Method Summary collapse
-
#call ⇒ Object
Returns a hash of column_name => [index_info, …] for the model’s table.
-
#initialize(model) ⇒ IndexInspector
constructor
A new instance of IndexInspector.
Constructor Details
#initialize(model) ⇒ IndexInspector
Returns a new instance of IndexInspector.
6 7 8 |
# File 'lib/rails_visualizer/schema/index_inspector.rb', line 6 def initialize(model) @model = model end |
Instance Method Details
#call ⇒ Object
Returns a hash of column_name => [index_info, …] for the model’s table.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rails_visualizer/schema/index_inspector.rb', line 11 def call return {} unless safe_table_exists? safe_indexes.each_with_object({}) do |index, hash| next unless index.columns.is_a?(Array) index.columns.each do |column| hash[column] ||= [] hash[column] << { name: index.name, unique: index.unique, columns: index.columns } end end end |