Class: SqlChatbot::Services::ModelIntrospector
- Inherits:
-
Object
- Object
- SqlChatbot::Services::ModelIntrospector
- Defined in:
- lib/sql_chatbot/services/model_introspector.rb
Defined Under Namespace
Classes: IntrospectionResult
Instance Method Summary collapse
-
#introspect ⇒ Object
Returns IntrospectionResult with: annotations — Hash[table_name => [annotation_strings]] soft_delete_tables — Set of tables using Paranoia/Discard gems enum_soft_delete_tables — Set of tables with enum deleted/archived values.
Instance Method Details
#introspect ⇒ Object
Returns IntrospectionResult with:
annotations — Hash[table_name => [annotation_strings]]
soft_delete_tables — Set of tables using Paranoia/Discard gems
enum_soft_delete_tables — Set of tables with enum deleted/archived values
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sql_chatbot/services/model_introspector.rb', line 14 def introspect annotations = Hash.new { |h, k| h[k] = Set.new } soft_delete_tables = Set.new enum_soft_delete_tables = Set.new models = discover_models models.each do |model| table = model.table_name detect_enums(model, table, annotations, enum_soft_delete_tables) detect_associations(model, table, annotations) detect_soft_delete_gem(model, table, soft_delete_tables) end IntrospectionResult.new( annotations: annotations.transform_values(&:to_a), soft_delete_tables: soft_delete_tables, enum_soft_delete_tables: enum_soft_delete_tables ) end |