Class: PageWrapper::PageGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_page_filesObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/page_generator.rb', line 7

def create_page_files
  model_path = File.join('app/models', class_path, "#{file_name}_page.rb")
  template 'model_page.rb', model_path

  serializer_path = File.join('app/serializers', class_path, "#{file_name}_page_serializer.rb")
  template 'model_serializer.rb', serializer_path

  controller_path = File.join('app/controllers', class_path, "#{file_name}_pages_controller.rb")
  template 'model_controller.rb', controller_path

  route "resources :#{class_name.underscore}_pages, only: [:index]"

  controller_path = File.join('app/assets/javascripts/controllers', class_path, "#{file_name}_page_controller.js.coffee")
  template 'page_controller.js.coffee', controller_path

  model_path = File.join('app/assets/javascripts/models', class_path, "#{file_name}_page.js.coffee")
  template 'page_model.js.coffee', model_path

  template_path = File.join('app/assets/javascripts/templates', class_path, "#{file_name}_page.handlebars")
  template 'page_template.handlebars', template_path

  view_path = File.join('app/assets/javascripts/views', class_path, "#{file_name}_page.js.coffee")
  template 'page_view.js.coffee', view_path
end

#show_readmeObject



32
33
34
# File 'lib/generators/page_generator.rb', line 32

def show_readme
  readme "README" if behavior == :invoke
end