Class: Oauth2FacebookGrantable::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/generators/oauth2_facebook_grantable/install_generator.rb', line 22

def self.next_migration_number(path)
  unless @prev_migration_nr
    @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
  else
    @prev_migration_nr += 1
  end
  @prev_migration_nr.to_s
end

.source_rootObject



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

def self.source_root
  @source_root ||= File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

#copy_migrationsObject

Generator Code. Remember this is just suped-up Thor so methods are executed in order



17
18
19
20
# File 'lib/generators/oauth2_facebook_grantable/install_generator.rb', line 17

def copy_migrations
  @table_name = options[:table_name]
  migration_template "migration_add_column.rb", "db/migrate/add_facebook_identifier_to_#{@table_name}"
end