Class: Rooq::Generator::CodeGenerator

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/rooq/generator/code_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(schema_info, typed: true, namespace: "Schema") ⇒ void

Parameters:

  • schema_info (Array<T.untyped>)
  • typed (Boolean) (defaults to: true)
  • namespace (String) (defaults to: "Schema")


12
13
14
15
16
# File 'lib/rooq/generator/code_generator.rb', line 12

def initialize(schema_info, typed: true, namespace: "Schema")
  @schema_info = schema_info
  @typed = typed
  @namespace = namespace
end

Instance Method Details

#generateString

Returns:

  • (String)


19
20
21
22
23
24
25
26
27
# File 'lib/rooq/generator/code_generator.rb', line 19

def generate
  tables_code = @schema_info.map { |table_info| generate_table(table_info) }

  if @typed
    generate_typed(tables_code)
  else
    generate_untyped(tables_code)
  end
end