lib/hanami/commands/generate/model.rb in hanami-1.0.0.beta2 vs lib/hanami/commands/generate/model.rb in hanami-1.0.0.beta3

- old
+ new

@@ -1,15 +1,24 @@ require 'hanami/commands/generate/abstract' require 'hanami/commands/generate/migration' module Hanami + # @api private module Commands + # @api private class Generate + # @api private class Model < Abstract - attr_reader :input, :model_name, :table_name + # @api private + attr_reader :input + # @api private + attr_reader :model_name + # @api private + attr_reader :table_name + # @api private def initialize(options, model_name) super(options) @input = Utils::String.new(model_name).underscore @model_name = Utils::String.new(@input).classify @table_name = Utils::String.new(@input).pluralize @@ -19,20 +28,22 @@ end assert_model_name! end + # @api private def map_templates add_mapping('entity.rb.tt', entity_path) add_mapping('repository.rb.tt', repository_path) unless skip_migration? add_mapping('migration.rb.tt', migration_path) end add_mapping("entity_spec.#{ test_framework.framework }.tt", entity_spec_path,) add_mapping("repository_spec.#{ test_framework.framework }.tt", repository_spec_path) end + # @api private def template_options { model_name: model_name, table_name: table_name } @@ -65,13 +76,15 @@ unless model_name.match(/^[a-z]/i) raise ArgumentError.new("Invalid model name. The model name shouldn't begin with a number.") end end + # @api private def skip_migration? options.fetch(:skip_migration, false) end + # @api private def model_root Pathname.new('lib').join(project_name) end # @since 0.5.0