Class: RailsLens::Analyzers::Notes
- Defined in:
- lib/rails_lens/analyzers/notes.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(model_class) ⇒ Notes
constructor
A new instance of Notes.
Methods included from ErrorHandling
Constructor Details
#initialize(model_class) ⇒ Notes
Returns a new instance of Notes.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rails_lens/analyzers/notes.rb', line 6 def initialize(model_class) super @connection = model_class.connection @table_name = model_class.table_name rescue ActiveRecord::ConnectionNotEstablished => e RailsLens.logger.debug { "No database connection for #{model_class.name}: #{e.}" } @connection = nil @table_name = nil rescue NoMethodError => e RailsLens.logger.debug { "Failed to initialize Notes analyzer for #{model_class.name}: #{e.}" } @connection = nil @table_name = nil rescue RuntimeError => e RailsLens.logger.debug { "Runtime error initializing Notes analyzer for #{model_class.name}: #{e.}" } @connection = nil @table_name = nil end |
Instance Method Details
#analyze ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rails_lens/analyzers/notes.rb', line 24 def analyze return nil unless @connection && @table_name notes = [] # Check if this model is backed by a view is_view = ModelDetector.view_exists?(model_class) if is_view # For views, add view-specific checks notes.concat(analyze_view_readonly) notes.concat(analyze_view_gotchas) else # For tables, run all standard checks notes.concat(analyze_indexes) notes.concat(analyze_foreign_keys) notes.concat(analyze_associations) notes.concat(analyze_columns) notes.concat(analyze_performance) notes.concat(analyze_best_practices) end notes.compact.uniq rescue ActiveRecord::StatementInvalid => e RailsLens.logger.debug { "Database error analyzing notes for #{@table_name}: #{e.}" } nil rescue NoMethodError => e RailsLens.logger.debug { "Method error analyzing notes for #{@table_name}: #{e.}" } nil end |