Class: ActiveGraph::Generators::DeviseGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- ActiveGraph::Generators::DeviseGenerator
- Includes:
- Devise::Generators::OrmHelpers
- Defined in:
- lib/generators/active_graph/devise_generator.rb
Instance Method Summary collapse
- #copy_devise_migration ⇒ Object
- #generate_model ⇒ Object
- #inject_devise_content ⇒ Object
- #inject_field_types ⇒ Object
- #migration_data ⇒ Object
- #migration_version ⇒ Object
- #rails5? ⇒ Boolean
Instance Method Details
#copy_devise_migration ⇒ Object
8 9 10 11 12 13 |
# File 'lib/generators/active_graph/devise_generator.rb', line 8 def copy_devise_migration file_path = "db/neo4j/migrate/#{Time.now.utc.strftime('%Y%m%d%H%M%S')}_devise_create_user_constraints_and_indexes.rb" text = File.read(File.('./templates/migration.rb.erb', File.dirname(__FILE__))) label_string = name create_file file_path, ERB.new(text).result(binding) end |
#generate_model ⇒ Object
15 16 17 |
# File 'lib/generators/active_graph/devise_generator.rb', line 15 def generate_model invoke 'active_graph:model', [name] unless model_exists? && behavior == :invoke end |
#inject_devise_content ⇒ Object
23 24 25 |
# File 'lib/generators/active_graph/devise_generator.rb', line 23 def inject_devise_content inject_into_file model_path, migration_data , after: /Neo4j::ActiveNode\n/ if model_exists? end |
#inject_field_types ⇒ Object
19 20 21 |
# File 'lib/generators/active_graph/devise_generator.rb', line 19 def inject_field_types inject_into_file model_path, model_contents , after: /Neo4j::ActiveNode\n/ if model_exists? end |
#migration_data ⇒ Object
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 |
# File 'lib/generators/active_graph/devise_generator.rb', line 27 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 :created_at, type: DateTime property :updated_at, type: DateTime ## Database authenticatable property :email, type: String, default: '' validates :email, presence: true property :encrypted_password ## If you include devise modules, uncomment the properties below. ## Recoverable property :reset_password_token property :reset_password_sent_at, type: DateTime ## Rememberable property :remember_created_at, type: DateTime ## Trackable property :sign_in_count, type: Integer, default: 0 validates :sign_in_count, presence: true 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 # property :confirmed_at, type: DateTime # property :confirmation_sent_at, type: DateTime # property :unconfirmed_email # Only if using reconfirmable ## Lockable # property :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts # validates :failed_attempts, presence: true # property :unlock_token, type: String # Only if unlock strategy is :email or :both # property :locked_at, type: DateTime ## Token authenticatable # property :authentication_token, type: String RUBY end |
#migration_version ⇒ Object
85 86 87 88 89 |
# File 'lib/generators/active_graph/devise_generator.rb', line 85 def migration_version if rails5? "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end end |
#rails5? ⇒ Boolean
81 82 83 |
# File 'lib/generators/active_graph/devise_generator.rb', line 81 def rails5? Rails.version.start_with? '5' end |