Class: Faalis::Generators::ViewsGenerator

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) copy_views



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/generators/faalis/views_generator.rb', line 10

def copy_views
  if views_to_copy.empty?
    views = ['index', 'show', 'new', 'edit', 'create', 'update', 'destroy']
  else
    views = views_to_copy
  end

  empty_directory "app/views/#{resources}"

  if views.include? 'index'
    copy_file 'views/faalis/dashboard/resource/index.html.slim', "app/views/#{resources}/index.html.slim"
  end

  if views.include? 'show'
    copy_file 'views/faalis/dashboard/resource/show.html.slim', "app/views/#{resources}/show.html.slim"
  end

  if views.include? 'new'
    copy_file 'views/faalis/dashboard/resource/new.html.slim', "app/views/#{resources}/new.html.slim"
    copy_file 'views/faalis/dashboard/resource/_form.html.slim', "app/views/#{resources}/_form.html.slim"
  end

  if views.include? 'edit'
    copy_file 'views/faalis/dashboard/resource/edit.html.slim', "app/views/#{resources}/edit.html.slim"
    copy_file 'views/faalis/dashboard/resource/_form.html.slim', "app/views/#{resources}/_form.html.slim"
  end

  if views.include? 'create'
    copy_file 'views/faalis/dashboard/resource/create.js.erb', "app/views/#{resources}/create.js.erb"
  end

  if views.include? 'update'
    copy_file 'views/faalis/dashboard/resource/update.js.erb', "app/views/#{resources}/update.js.erb"
  end

  if views.include? 'destroy'
    copy_file 'views/faalis/dashboard/resource/destroy.js.erb', "app/views/#{resources}/destroy.js.erb"
  end
end

- (Object) resources (private)



52
53
54
# File 'lib/generators/faalis/views_generator.rb', line 52

def resources
  resource_name.underscore.pluralize
end