Class: FriendshipGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- FriendshipGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/friendship/friendship_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #class_name ⇒ Object
- #generate_class ⇒ Object
- #generate_migration ⇒ Object
- #migration_class_name ⇒ Object
- #migration_file_name ⇒ Object
- #migration_name ⇒ Object
- #model_filename ⇒ Object
- #orig_class_name_cam ⇒ Object
- #orig_class_name_und ⇒ Object
- #table_name ⇒ Object
Class Method Details
.next_migration_number(path) ⇒ Object
49 50 51 52 |
# File 'lib/generators/friendship/friendship_generator.rb', line 49 def self.next_migration_number(path) require 'rails/generators/active_record' ActiveRecord::Generators::Base.next_migration_number path end |
Instance Method Details
#class_name ⇒ Object
40 41 42 |
# File 'lib/generators/friendship/friendship_generator.rb', line 40 def class_name "#{orig_class_name_cam}Friendship" end |
#generate_class ⇒ Object
11 12 13 |
# File 'lib/generators/friendship/friendship_generator.rb', line 11 def generate_class template "friendship_model.rb.erb", "app/models/#{model_filename}" end |
#generate_migration ⇒ Object
7 8 9 |
# File 'lib/generators/friendship/friendship_generator.rb', line 7 def generate_migration migration_template "friendship_migration.rb.erb", "db/migrate/#{migration_file_name}" end |
#migration_class_name ⇒ Object
25 26 27 |
# File 'lib/generators/friendship/friendship_generator.rb', line 25 def migration_class_name migration_name.camelize end |
#migration_file_name ⇒ Object
21 22 23 |
# File 'lib/generators/friendship/friendship_generator.rb', line 21 def migration_file_name "#{migration_name}.rb" end |
#migration_name ⇒ Object
17 18 19 |
# File 'lib/generators/friendship/friendship_generator.rb', line 17 def migration_name "create_#{name.underscore}_friendship" end |
#model_filename ⇒ Object
44 45 46 |
# File 'lib/generators/friendship/friendship_generator.rb', line 44 def model_filename "#{orig_class_name_und}_friendship.rb" end |
#orig_class_name_cam ⇒ Object
32 33 34 |
# File 'lib/generators/friendship/friendship_generator.rb', line 32 def orig_class_name_cam "#{name.camelize}" end |
#orig_class_name_und ⇒ Object
29 30 31 |
# File 'lib/generators/friendship/friendship_generator.rb', line 29 def orig_class_name_und "#{name.underscore.downcase}" end |
#table_name ⇒ Object
36 37 38 |
# File 'lib/generators/friendship/friendship_generator.rb', line 36 def table_name ":#{orig_class_name_und}_friendships" end |