Class: Maglev::SchemaCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/maglev/schema_compiler.rb

Defined Under Namespace

Classes: CompiledRelation, CompiledSchema

Constant Summary collapse

SUPPORTED_MACROS =
%i[belongs_to has_one has_many].freeze

Instance Method Summary collapse

Constructor Details

#initialize(config, max_depth: Maglev.configuration.max_relation_depth) ⇒ SchemaCompiler

Returns a new instance of SchemaCompiler.



13
14
15
16
# File 'lib/maglev/schema_compiler.rb', line 13

def initialize(config, max_depth: Maglev.configuration.max_relation_depth)
  @config = config
  @max_depth = max_depth
end

Instance Method Details

#compileObject



18
19
20
# File 'lib/maglev/schema_compiler.rb', line 18

def compile
  CompiledSchema.new(@config.model_class, @config.relations.map { |relation| compile_relation(relation) }.freeze)
end