class Grape::ControllerGenerator

Public Instance Methods

generate_controller() click to toggle source
# File lib/generators/grape/controller/controller_generator.rb, line 10
def generate_controller
  template 'controller.erb', "#{options[:controller_path]}/#{model_name.pluralize.underscore}.rb"
end
generate_controller_specs() click to toggle source
# File lib/generators/grape/controller/controller_generator.rb, line 14
def generate_controller_specs
  unless options[:skip_controller_tests]
    template 'controller_spec.erb', "spec/requests/#{model_name.singularize.underscore}_spec.rb"
  end
end

Protected Instance Methods

attribute_is_id?(attribute) click to toggle source
# File lib/generators/grape/controller/controller_generator.rb, line 25
def attribute_is_id?(attribute)
  attribute.split(':').first.last(3) == "_id"
end
attribute_name(attribute) click to toggle source
# File lib/generators/grape/controller/controller_generator.rb, line 21
def attribute_name(attribute)
  attribute.split(':').first
end
attribute_without_id(attribute) click to toggle source
# File lib/generators/grape/controller/controller_generator.rb, line 29
def attribute_without_id(attribute)
  attribute.split(':').first[0..-4]
end