Class: Lotus::Commands::Generate::Model

Inherits:
Abstract
  • Object
show all
Defined in:
lib/lotus/commands/generate/model.rb

Overview

Since:

  • 0.1.0

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, #destroy, #generator, #post_process_templates, #process_templates, #start, #target_path, #template_source_path

Constructor Details

#initialize(options, model_name) ⇒ Model

Returns a new instance of Model.

Since:

  • 0.1.0



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

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

  assert_model_name!
end

Instance Attribute Details

#model_nameObject (readonly)

Since:

  • 0.1.0



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

def model_name
  @model_name
end

Instance Method Details

#map_templatesObject

Since:

  • 0.1.0



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

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

Since:

  • 0.1.0



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

def template_options
  {
    model_name: model_name
  }
end