class Nyauth::NyauthGenerator
Public Instance Methods
copy_nyauth_migration()
click to toggle source
# File lib/generators/nyauth/nyauth_generator.rb, line 6 def copy_nyauth_migration migration_template "migration.rb", "db/migrate/add_nyauth_to_#{table_name}.rb" end
inject_devise_content()
click to toggle source
# File lib/generators/nyauth/nyauth_generator.rb, line 10 def inject_devise_content content = model_contents class_path = if namespaced? class_name.to_s.split("::") else [class_name] end indent_depth = class_path.size - 1 content = content.split("\n").map { |line| " " * indent_depth + line } .join("\n") << "\n" inject_into_class(model_path, class_path.last, content) if model_exists? end
migration_data()
click to toggle source
# File lib/generators/nyauth/nyauth_generator.rb, line 25 def migration_data <<RUBY # Authenticatable t.string :email, null: false t.string :password_digest, null: false t.string :password_salt, null: false t.string :reset_password_key t.datetime :reset_password_key_expired_at # Confirmable #t.datetime :confirmed_at #t.string :confirmation_key #t.datetime :confirmation_key_expired_at RUBY end
model_contents()
click to toggle source
# File lib/generators/nyauth/nyauth_generator.rb, line 40 def model_contents <<RUBY include Nyauth::Authenticatable #include Nyauth::Confirmable RUBY end
Private Instance Methods
model_exists?()
click to toggle source
# File lib/generators/nyauth/nyauth_generator.rb, line 49 def model_exists? File.exists?(File.join(destination_root, model_path)) end
model_path()
click to toggle source
# File lib/generators/nyauth/nyauth_generator.rb, line 53 def model_path @model_path ||= File.join("app", "models", "#{file_path}.rb") end