Sha256: b17d1fac843ab87a2e79c118bbfdf8a99bdd6155303232960c76c86133f6b302
Contents?: true
Size: 1.35 KB
Versions: 25
Compression:
Stored size: 1.35 KB
Contents
module JsonVoorhees class EngineCreateControllerGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) argument :module_name, :type => :string argument :resource_name, :type => :string argument :api_version, :type => :string, :default => "1" argument :attributes, type: :array, default: [], banner: "field:type field:type" class_option :arcadex, :type => :boolean, :default => true, :description => "Include authorization in controller" def sprint if options.arcadex? template "controller_template.rb.erb", "app/controllers/#{module_name.underscore}/api/v#{api_version}/#{resource_plural}_controller.rb" else template "no_auth_controller_template.rb.erb", "app/controllers/#{module_name.underscore}/api/v#{api_version}/#{resource_plural}_controller.rb" end end private def params_list params = [] attributes.each do |pair| elem = pair.split(/:/)[0] field = ":#{elem}" params << field end return params.join(",") end def resource_singular resource_name.underscore.singularize end def resource_plural resource_name.underscore.pluralize end def resource_camel resource_name.camelize.singularize end def module_camel module_name.camelize end def module_snake module_name.underscore.downcase end end end
Version data entries
25 entries across 25 versions & 1 rubygems