Class: Socialite::Generators::EntitiesGenerator

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

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object


14
15
16
17
18
19
20
21
# File 'lib/generators/socialite/entities_generator.rb', line 14

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

Instance Method Details

#generate_socialite_filesObject


23
24
25
26
27
28
29
30
# File 'lib/generators/socialite/entities_generator.rb', line 23

def generate_socialite_files
  if !user_class_exists? || !identity_class_exists?
    migration_template "models/migration.rb.erb", "db/migrate/create_socialite.rb"
  end

  template("models/user.rb.erb",     "app/models/#{singular_user_name}.rb")     unless user_class_exists?
  template("models/identity.rb.erb", "app/models/#{singular_identity_name}.rb") unless identity_class_exists?
end