Class: Hanami::Commands::Generate::Model

Inherits:
Abstract show all
Defined in:
lib/hanami/commands/generate/model.rb

Instance Attribute Summary collapse

Attributes inherited from Abstract

#options, #target_path

Instance Method Summary collapse

Methods inherited from Abstract

#template_source_path

Methods included from Generators::Generatable

#add_mapping, #argument_blank?, #destroy, #generator, #post_process_templates, #process_templates, #start, #target_path, #template_source_path

Methods inherited from Command

inherited

Constructor Details

#initialize(options, model_name) ⇒ Model

Returns a new instance of Model


10
11
12
13
14
15
16
# File 'lib/hanami/commands/generate/model.rb', line 10

def initialize(options, model_name)
  super(options)
  @input      = Utils::String.new(model_name).underscore
  @model_name = Utils::String.new(@input).classify

  assert_model_name!
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input


8
9
10
# File 'lib/hanami/commands/generate/model.rb', line 8

def input
  @input
end

#model_nameObject (readonly)

Returns the value of attribute model_name


8
9
10
# File 'lib/hanami/commands/generate/model.rb', line 8

def model_name
  @model_name
end

Instance Method Details

#map_templatesObject


18
19
20
21
22
23
# File 'lib/hanami/commands/generate/model.rb', line 18

def map_templates
  add_mapping('entity.rb.tt', entity_path)
  add_mapping('repository.rb.tt', repository_path)
  add_mapping("entity_spec.#{ test_framework.framework }.tt", entity_spec_path,)
  add_mapping("repository_spec.#{ test_framework.framework }.tt", repository_spec_path)
end

#template_optionsObject


25
26
27
28
29
# File 'lib/hanami/commands/generate/model.rb', line 25

def template_options
  {
    model_name: model_name
  }
end