Class: Petergate::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/petergate/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



11
12
13
14
# File 'lib/generators/petergate/install_generator.rb', line 11

def self.next_migration_number(path)
  sleep 1
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#create_migrationsObject

RUBY

  end
end


40
41
42
43
44
45
# File 'lib/generators/petergate/install_generator.rb', line 40

def create_migrations
  Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
    name = File.basename(filepath)
    migration_template "migrations/#{name}", "db/migrate/#{name}"
  end
end

#insert_into_user_modelObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/petergate/install_generator.rb', line 16

def insert_into_user_model
  inject_into_file "app/models/user.rb", after: /^class\sUser < ActiveRecord::Base/ do
    "\n  ################################################################################ \n  ## PeterGate Roles\n  ## The :user role is added by default and shouldn't be included in this list.\n  petergate(roles: [:admin, :company_admin])\n  ################################################################################\n \n    RUBY\n  end\nend\n"