Sha256: 3891df843ba85b10cbe7db8482c4fa3125a4ca5952d9bcb6d01c340aab7ffef4

Contents?: true

Size: 626 Bytes

Versions: 1

Compression:

Stored size: 626 Bytes

Contents

# frozen_string_literal: true

module Sparrow
  #
  # 创建一个自定义的创建 Sparrow::Base 的类。
  #
  # @author Shiner <shiner527@hotmail.com>
  #
  class EntityGenerator < Rails::Generators::NamedBase
    # 默认的引入应用的相对安装路径
    TARGET_RELATIVE_PATH = 'app/entities'

    source_root File.expand_path('templates', __dir__)

    #
    # 复制模板文件到对应 Rails 项目中
    #
    def create_sparrow_class_file
      sparrow_file_path = ::File.join(TARGET_RELATIVE_PATH, class_path, "#{file_name}.rb")
      template 'sparrow_entity.rb.erb', sparrow_file_path
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sparrow-entity-0.1.1 lib/generators/sparrow/entity/entity_generator.rb