Class: RedisFriendshipsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RedisFriendshipsGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/redis_friendships/redis_friendships_generator.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#add_gems_and_initializer ⇒ Object
29 30 31 32 33 34 |
# File 'lib/generators/redis_friendships/redis_friendships_generator.rb', line 29 def add_gems_and_initializer unless File.read(destination_path("Gemfile")).include? "redis" gem "redis" template"redis.rb", "config/initializers/redis.rb" end end |
#create_migration ⇒ Object
25 26 27 |
# File 'lib/generators/redis_friendships/redis_friendships_generator.rb', line 25 def create_migration migration_template 'user_migration.rb', "db/migrate/create_#{user_plural_name}.rb" if File.exist?(File.join(Dir.pwd, "app", "models", "#{user_singular_name}.rb")) end |
#create_model_files ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/redis_friendships/redis_friendships_generator.rb', line 13 def create_model_files if File.exist?(File.join(Dir.pwd, "app", "models", "#{user_singular_name}.rb")) template('user_injection_code.rb', "temp_file.rb") #I need to READ this with the erb in it code = IO.read(File.join(Dir.pwd,"temp_file.rb")) inject_into_class(File.join(Dir.pwd, "app", "models", "#{user_singular_name}.rb"), user_class_name, code) File.delete(File.join(Dir.pwd,"temp_file.rb")) else template 'user.rb', "app/models/#{user_singular_name}.rb" end template 'friendship.rb', "app/models/#{friendship_singular_name}.rb" end |