class TheRoleGenerator

Public Instance Methods

generate_controllers() click to toggle source

bundle exec rails g the_role NAME

# File lib/generators/the_role/the_role_generator.rb, line 6
def generate_controllers
  if gen_name == 'install'
    cp_models
    cp_config
  elsif gen_name == 'config'
    cp_config
  elsif gen_name == 'models'
    cp_models
  elsif gen_name == 'controllers'
    cp_controllers
  elsif gen_name == 'locales'
    cp_locales
  elsif gen_name == 'help'
    cp_help
  else
    puts 'TheRole Generator - wrong Name'
    puts 'Try to use install'
  end
end

Private Instance Methods

cp_config() click to toggle source
# File lib/generators/the_role/the_role_generator.rb, line 32
def cp_config
  copy_file 'config/initializers/the_role.rb',
            'config/initializers/the_role.rb'
end
cp_controllers() click to toggle source
# File lib/generators/the_role/the_role_generator.rb, line 42
def cp_controllers
  directory 'app/controllers',
            'app/controllers'
end
cp_help() click to toggle source
# File lib/generators/the_role/the_role_generator.rb, line 52
def cp_help
  puts File.read "#{ TheRoleGenerator.source_root }/lib/generators/the_role/USAGE"
end
cp_locales() click to toggle source
# File lib/generators/the_role/the_role_generator.rb, line 47
def cp_locales
  directory 'config/locales',
            'config/locales'
end
cp_models() click to toggle source
# File lib/generators/the_role/the_role_generator.rb, line 37
def cp_models
  copy_file 'app/models/_templates_/role.rb',
            'app/models/role.rb'
end
gen_name() click to toggle source
# File lib/generators/the_role/the_role_generator.rb, line 28
def gen_name
  name.to_s.downcase
end