Class: Neo4j::Generators::DeviseGenerator

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

Instance Method Summary collapse

Instance Method Details

#generate_modelObject



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

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

#inject_devise_contentObject



17
18
19
# File 'lib/generators/neo4j/devise_generator.rb', line 17

def inject_devise_content
  inject_into_file model_path,  migration_data , :after => /Neo4j::ActiveNode\n/ if model_exists?
end

#inject_field_typesObject



13
14
15
# File 'lib/generators/neo4j/devise_generator.rb', line 13

def inject_field_types
  inject_into_file model_path, model_contents , :after => /Neo4j::ActiveNode\n/ if model_exists?
end

#migration_dataObject



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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/generators/neo4j/devise_generator.rb', line 22

def migration_data
<<RUBY
    #
    # Neo4j.rb needs to have property definitions before any validations. So, the property block needs to come before
    # loading your devise modules.
    #
    # If you add another devise module (such as :lockable, :confirmable, or :token_authenticatable), be sure to
    # uncomment the property definitions for those modules. Otherwise, the unused property definitions can be deleted.
    #

     property :username, type: String
     property :facebook_token, type: String
     index :facebook_token

     property :created_at, type: DateTime
     property :updated_at, type: DateTime

     ## Database authenticatable
     property :email, type: String, null: false, default: ""
     index :email

     property :encrypted_password

     ## If you include devise modules, uncomment the properties below.

     ## Rememberable
     property :remember_created_at, type: DateTime
     property :remember_token
     index :remember_token


     ## Recoverable
     property :reset_password_token
     index :reset_password_token
     property :reset_password_sent_at, type: DateTime

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

     ## Confirmable
     # property :confirmation_token
     # index :confirmation_token
     # property :confirmed_at, type: DateTime
     # property :confirmation_sent_at, type: DateTime

     ## Lockable
     #  property :failed_attempts, type: Integer, default: 0
     # property :locked_at, type: DateTime
     #  property :unlock_token, type: String,
     # index :unlock_token

## Token authenticatable
# property :authentication_token, type: String, null: true, index: :exact

RUBY
end