Class: Sufia::Models::ProxiesGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Sufia::Models::ProxiesGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/sufia/models/proxies_generator.rb
Class Method Summary collapse
-
.next_migration_number(path) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
- #banner ⇒ Object
-
#copy_migrations ⇒ Object
Setup the database migrations.
Class Method Details
.next_migration_number(path) ⇒ Object
Implement the required interface for Rails::Generators::Migration. taken from github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/generators/sufia/models/proxies_generator.rb', line 16 def self.next_migration_number(path) if @prev_migration_nr @prev_migration_nr += 1 else if last_migration = Dir[File.join(path, '*.rb')].sort.last @prev_migration_nr = last_migration.sub(File.join(path, '/'), '').to_i + 1 else @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i end end @prev_migration_nr.to_s end |
Instance Method Details
#banner ⇒ Object
29 30 31 |
# File 'lib/generators/sufia/models/proxies_generator.rb', line 29 def say_status("warning", "ADDING PROXY/TRANSFER-RELATED SUFIA MODELS", :yellow) end |
#copy_migrations ⇒ Object
Setup the database migrations
34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/sufia/models/proxies_generator.rb', line 34 def copy_migrations # Can't get this any more DRY, because we need this order. [ 'create_proxy_deposit_rights.rb', 'create_proxy_deposit_requests.rb' ].each do |file| better_migration_template file end end |