Class: Hanami::CLI::Commands::Generate::Model Private

Inherits:
Command
  • Object
show all
Defined in:
lib/hanami/cli/commands/generate/model.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.1.0

Instance Method Summary collapse

Methods inherited from Command

inherited, #initialize

Constructor Details

This class inherits a constructor from Hanami::CLI::Commands::Command

Instance Method Details

#call(model:, **options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.1.0


24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hanami/cli/commands/generate/model.rb', line 24

def call(model:, **options)
  model     = Utils::String.underscore(model)
  relation  = relation_name(options, model)
  migration = "create_#{relation}"
  context   = Context.new(model: model, relation: relation, migration: migration, test: options.fetch(:test), override_relation_name: override_relation_name?(options), options: options)

  assert_valid_relation!(context)

  generate_entity(context)
  generate_repository(context)
  generate_migration(context)
  generate_entity_spec(context)
  generate_repository_spec(context)
end