Class: ApiControllerGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/api_controller/api_controller_generator.rb

Instance Method Summary collapse

Instance Method Details

#adjust_routesObject



19
20
21
# File 'lib/generators/api_controller/api_controller_generator.rb', line 19

def adjust_routes
  create_routes
end

#create_api_directoriesObject



8
9
10
11
# File 'lib/generators/api_controller/api_controller_generator.rb', line 8

def create_api_directories
  make_dir "#{RAILS_ROOT}/app/controllers/api"
  make_dir "#{RAILS_ROOT}/app/controllers/api/v#{version}"
end

#generate_api_controllerObject



13
14
15
16
17
# File 'lib/generators/api_controller/api_controller_generator.rb', line 13

def generate_api_controller
  structure = "api/v#{version}/"
  template 'api_controller.rb', "app/controllers/#{structure}#{model}_api_controller.rb"
  template 'api_controller_test.rb', "test/functional/#{structure}#{model}_api_test.rb"
end