Class: Jsonapi::ResourceGenerator

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

Instance Method Summary collapse

Instance Method Details

#copy_resource_fileObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/jsonapi/resource_generator.rb', line 19

def copy_resource_file
  unless model_klass
    raise "You must define a #{class_name} model before generating the corresponding resource."
  end

  generate_controller
  generate_serializer
  generate_application_resource unless application_resource_defined?
  generate_spec_payload

  if actions?('create', 'update')
    generate_strong_resource
  end

  generate_route
  generate_tests
  generate_resource
  generate_swagger if docs_controller?
end