Class: DataMapper::Generators::DeviseGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Devise::Generators::OrmHelpers
Defined in:
lib/generators/data_mapper/devise_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_modelObject



8
9
10
# File 'lib/generators/data_mapper/devise_generator.rb', line 8

def generate_model
  invoke "data_mapper:model", [name] unless model_exists? && behavior == :invoke
end

#inject_devise_contentObject



16
17
18
# File 'lib/generators/data_mapper/devise_generator.rb', line 16

def inject_devise_content
  inject_into_file model_path, model_contents, :after => "include DataMapper::Resource\n" if model_exists?
end

#inject_property_typesObject



12
13
14
# File 'lib/generators/data_mapper/devise_generator.rb', line 12

def inject_property_types
  inject_into_file model_path, migration_data, :after => "include DataMapper::Resource\n" if model_exists?
end

#migration_dataObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/generators/data_mapper/devise_generator.rb', line 20

def migration_data
<<RUBY
  ## Database authenticatable
  property :email,              String, :required => true, :default => "", :length => 255
  property :encrypted_password, String, :required => true, :default => "", :length => 255

  ## Recoverable
  property :reset_password_token,   String
  property :reset_password_sent_at, DateTime

  ## Rememberable
  property :remember_created_at, DateTime

  ## Trackable
  property :sign_in_count,      Integer, :default => 0
  property :current_sign_in_at, DateTime
  property :last_sign_in_at,    DateTime
  property :current_sign_in_ip, String
  property :last_sign_in_ip,    String

  ## Encryptable
  # property :password_salt, String

  ## Confirmable
  # property :confirmation_token,   String
  # property :confirmed_at,         DateTime
  # property :confirmation_sent_at, DateTime
  # property :unconfirmed_email,    String # Only if using reconfirmable

  ## Lockable
  # property :failed_attempts, Integer, :default => 0 # Only if lock strategy is :failed_attempts
  # property :unlock_token,    String # Only if unlock strategy is :email or :both
  # property :locked_at,       DateTime

  ## Token authenticatable
  # property :authentication_token, String, :length => 255

  ## Invitable
  # property :invitation_token, String, :length => 255
RUBY
end