Class: Coatepec::Introspection::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/coatepec/introspection/model.rb

Overview

Returns bounded ActiveRecord schema and class metadata for a single model, for the rails_model MCP tool. No records, no SQL beyond schema reflection, no method dispatch on the resolved class beyond pure introspection APIs.

Constant Summary collapse

NAME_PATTERN =
/\A[A-Z]\w*(?:::[A-Z]\w*)*\z/
MAX_ITEMS =
200
EMPTY_TABLE_METADATA =
{ table_name: nil, primary_key: nil, columns: [] }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Model

Returns a new instance of Model.



14
15
16
# File 'lib/coatepec/introspection/model.rb', line 14

def initialize(name)
  @name = name
end

Instance Method Details

#callObject



18
19
20
21
22
23
# File 'lib/coatepec/introspection/model.rb', line 18

def call
  validate_name!
  klass = resolve!
  validate_active_record!(klass)
  (klass)
end