Class: Batman::Generators::ViewGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Common
Defined in:
lib/generators/batman/view_generator.rb

Instance Method Summary collapse

Methods included from Common

included

Instance Method Details

#create_directoryObject



11
12
13
14
15
16
17
# File 'lib/generators/batman/view_generator.rb', line 11

def create_directory
  return if actions.length == 0

  with_app_name do
    empty_directory "#{app_path}/views/#{plural_name.downcase}"
  end
end

#create_filesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/batman/view_generator.rb', line 19

def create_files
  with_app_name do
    if actions.length == 0
      @file = "#{file_name}_view".downcase
      template "batman/view.coffee", "#{app_path}/views/#{@file}.js.coffee"
    else
      actions.each do |file|
        @file = "#{plural_name}_#{file}_view".downcase
        template "batman/view.coffee", "#{app_path}/views/#{plural_name.downcase}/#{@file}.js.coffee"
      end
    end
  end
end