Class: Sufia::Models::UserStatsGenerator
- Inherits:
-
AbstractMigrationGenerator
- Object
- Rails::Generators::Base
- AbstractMigrationGenerator
- Sufia::Models::UserStatsGenerator
- Defined in:
- lib/generators/sufia/models/user_stats_generator.rb
Instance Method Summary collapse
- #add_stats_mixin_to_user_model ⇒ Object
- #banner ⇒ Object
-
#copy_migrations ⇒ Object
Setup the database migrations.
Methods inherited from AbstractMigrationGenerator
Instance Method Details
#add_stats_mixin_to_user_model ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/generators/sufia/models/user_stats_generator.rb', line 20 def add_stats_mixin_to_user_model file_path = "app/models/#{model_name.underscore}.rb" if File.exist?(file_path) inject_into_file file_path, after: /include Sufia\:\:User.*$/ do "\n include Sufia::UserUsageStats" end else puts " \e[31mFailure\e[0m Sufia requires a user object. This generator assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails g sufia:models:user_stats client" end end |
#banner ⇒ Object
11 12 13 |
# File 'lib/generators/sufia/models/user_stats_generator.rb', line 11 def say_status("info", "ADDING USER STATS-RELATED ABILITIES TO SUFIA MODELS", :blue) end |
#copy_migrations ⇒ Object
Setup the database migrations
16 17 18 |
# File 'lib/generators/sufia/models/user_stats_generator.rb', line 16 def copy_migrations better_migration_template 'create_user_stats.rb' end |