Class: Hanami::Commands::Generate::Model
- Defined in:
- lib/hanami/commands/generate/model.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
Attributes inherited from Abstract
Instance Method Summary collapse
-
#initialize(options, model_name) ⇒ Model
constructor
A new instance of Model.
- #map_templates ⇒ Object
- #template_options ⇒ Object
Methods inherited from Abstract
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
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(, model_name) super() @input = Utils::String.new(model_name).underscore @model_name = Utils::String.new(@input).classify assert_model_name! end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
8 9 10 |
# File 'lib/hanami/commands/generate/model.rb', line 8 def input @input end |
#model_name ⇒ Object (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_templates ⇒ Object
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_options ⇒ Object
25 26 27 28 29 |
# File 'lib/hanami/commands/generate/model.rb', line 25 def { model_name: model_name } end |