Class: Sufia::Models::ProxiesGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/sufia/models/proxies_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

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



29
30
31
# File 'lib/generators/sufia/models/proxies_generator.rb', line 29

def banner
  say_status("warning", "ADDING PROXY/TRANSFER-RELATED SUFIA MODELS", :yellow)
end

#copy_migrationsObject

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