Sha256: f9243a7c7aede7c567340f3731dc5d851053eae5a74a13e5cbb7e92551ef2499

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 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"

	  def sprint
	  	template "controller_template.rb.erb", "app/controllers/#{module_name.underscore}/api/v#{api_version}/#{resource_plural}_controller.rb"
	  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

13 entries across 13 versions & 1 rubygems

Version Path
json_voorhees-1.5.1 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.5.0 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.4.9 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.4.8 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.4.7 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.4.6 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.4.5 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.4.2 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.4.1 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.4.0 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.3.2 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.3.1 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb
json_voorhees-1.3.0 lib/generators/json_voorhees/engine_create_controller/engine_create_controller_generator.rb