Class: Domino::Scaffolder

Inherits:
Object
  • Object
show all
Defined in:
lib/domino/scaffolder.rb

Overview

Scaffolder: handles the generation of model, repository, service, blueprint, and controller files

Class Method Summary collapse

Class Method Details

.scaffold(tables: nil, namespace: nil, generate_model: true) ⇒ Object

Entrypoint: called from Domino.scaffold



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/domino/scaffolder.rb', line 11

def self.scaffold(tables: nil, namespace: nil, generate_model: true)
  connection = ActiveRecord::Base.connection
  tables ||= connection.tables.reject { |t| %w[schema_migrations ar_internal_metadata].include?(t) }
  # tables ||= connection.tables.reject { |t| t == "schema_migrations" }

  tables.each do |table|
    klass = table.singularize.camelize
    columns = connection.columns(table)
    ScaffoldRunner.new(klass, columns, namespace, generate_model).run
  end
end