Sha256: 40797107edd6b85a9f43650c7d70a5b93384e9b1655d07b9a0826217b1fdffb9
Contents?: true
Size: 1.34 KB
Versions: 29
Compression:
Stored size: 1.34 KB
Contents
require 'rails/generators/resource_helpers' module Symphonia module Generators class EntityController < Rails::Generators::NamedBase include Rails::Generators::ResourceHelpers source_root File.expand_path("../templates", __FILE__) check_class_collision suffix: "Controller" class_option :helper, type: :boolean class_option :orm, banner: "NAME", type: :string, required: true, desc: "ORM to generate the controller for" class_option :api, type: :boolean, desc: "Generates API controller" class_option :namespace, type: :string argument :attributes, type: :array, default: [], banner: "field:type field:type" def create_controller_files template_file = options.api? ? "api_controller.rb" : "controller.rb" template template_file, File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb") end hook_for :helper, in: :rails do |invoked| invoke invoked, [ controller_name ] end def namespace options['namespace'] && options['namespace'].safe_constantize || super end def show_helper # :doc: "#{singular_table_name}_path(@#{singular_table_name})" end def edit_helper # :doc: "edit_#{show_helper}" end def new_helper # :doc: "new_#{singular_table_name}_path" end end end end
Version data entries
29 entries across 29 versions & 1 rubygems