Class: Godmin::ResourceGenerator

Inherits:
Generators::NamedBase show all
Defined in:
lib/generators/godmin/resource/resource_generator.rb

Instance Method Summary collapse

Methods inherited from Generators::Base

source_paths

Instance Method Details

#add_navigationObject



10
11
12
13
14
15
16
# File 'lib/generators/godmin/resource/resource_generator.rb', line 10

def add_navigation
  append_to_file File.join("app/views", namespaced_path, "shared/_navigation.html.erb") do
    <<-END.strip_heredoc
      <%= navbar_item #{class_name} %>
    END
  end
end

#add_routeObject



6
7
8
# File 'lib/generators/godmin/resource/resource_generator.rb', line 6

def add_route
  invoke "resource_route"
end

#create_controllerObject



24
25
26
# File 'lib/generators/godmin/resource/resource_generator.rb', line 24

def create_controller
  template "resource_controller.rb", File.join("app/controllers", class_path, "#{file_name.pluralize}_controller.rb")
end

#create_modelObject



18
19
20
21
22
# File 'lib/generators/godmin/resource/resource_generator.rb', line 18

def create_model
  if namespaced?
    template "resource_model.rb", File.join("app/models", class_path, "#{file_name}.rb")
  end
end

#create_serviceObject



28
29
30
# File 'lib/generators/godmin/resource/resource_generator.rb', line 28

def create_service
  template "resource_service.rb", File.join("app/services", class_path, "#{file_name}_service.rb")
end