Sha256: 07c62f9399bb39ccd958e8e6617feba47c92df37d1856a6ef0ee74df08b06535
Contents?: true
Size: 1.35 KB
Versions: 11
Compression:
Stored size: 1.35 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.tt" : "controller.rb.tt" 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
11 entries across 11 versions & 1 rubygems