class Grape::ScaffoldGenerator

Public Instance Methods

generate_controller() click to toggle source
# File lib/generators/grape/scaffold/scaffold_generator.rb, line 22
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/scaffold/scaffold_generator.rb, line 26
def generate_controller_specs
  unless options[:skip_controller_tests]
    template 'controller_spec.erb', "spec/requests/#{model_name.singularize.underscore}_spec.rb"
  end
end
generate_model() click to toggle source
# File lib/generators/grape/scaffold/scaffold_generator.rb, line 12
def generate_model
  generate 'model', "#{model_name} #{attributes.join(' ')}"
end
generate_model_specs() click to toggle source
# File lib/generators/grape/scaffold/scaffold_generator.rb, line 16
def generate_model_specs
  unless options[:skip_model_tests]
    template 'model_spec.erb', "spec/models/#{model_name.singularize.underscore}_spec.rb"
  end
end

Protected Instance Methods

attribute_is_id?(attribute) click to toggle source
# File lib/generators/grape/scaffold/scaffold_generator.rb, line 37
def attribute_is_id?(attribute)
  attribute.split(':').first.last(3) == "_id"
end
attribute_name(attribute) click to toggle source
# File lib/generators/grape/scaffold/scaffold_generator.rb, line 33
def attribute_name(attribute)
  attribute.split(':').first
end
attribute_without_id(attribute) click to toggle source
# File lib/generators/grape/scaffold/scaffold_generator.rb, line 41
def attribute_without_id(attribute)
  attribute.split(':').first[0..-4]
end