Class: Platform::Generators::ApiGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/platform/api_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_proxy_fileObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/generators/platform/api_generator.rb', line 30

def create_proxy_file
  create_file "#{Rails.root}/app/controllers/api/#{file_name}_controller.rb", %Q{class Api::#{class_name}Controller < Api::BaseController
  def index
    ensure_get
    ensure_ids_provided
    ensure_ownership
    render_response page_models
  end

  def create
    ensure_logged_in
    # TODO: create object
    render_response object
  end
  
  def update
    ensure_logged_in
    ensure_ownership
    # TODO: update object
    render_response object
  end
  
  def delete
    ensure_logged_in
    ensure_post    
    ensure_ownership
    # TODO: delete object
    render_response success_message
  end
  
private

  def model_class
    #{class_name}
  end
  
end
}        
end