class Sequel::Generators::DeviseGenerator

Public Class Methods

next_migration_number(path) click to toggle source
# File lib/sequel/devise/generators/devise_generator.rb, line 18
def self.next_migration_number(path)
  Sequel::Generators::Base.next_migration_number(path)
end

Public Instance Methods

class_parts() click to toggle source
# File lib/sequel/devise/generators/devise_generator.rb, line 46
def class_parts
  if namespaced?
    class_name.to_s.split("::")
  else
    [class_name]
  end
end
copy_devise_migration() click to toggle source
# File lib/sequel/devise/generators/devise_generator.rb, line 22
def copy_devise_migration
  if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
    migration_template "migration_existing.rb.erb", "db/migrate/add_devise_to_#{table_name}"
  else
    migration_template "migration.rb.erb", "db/migrate/devise_create_#{table_name}"
  end
end
generate_model() click to toggle source
# File lib/sequel/devise/generators/devise_generator.rb, line 30
def generate_model
  invoke "sequel:model", [name], :migration => false unless model_exists? && behavior == :invoke
end
indent_depth() click to toggle source
# File lib/sequel/devise/generators/devise_generator.rb, line 54
def indent_depth
  class_parts.size - 1
end
inject_devise_content() click to toggle source
# File lib/sequel/devise/generators/devise_generator.rb, line 34
def inject_devise_content
  content = ("#{sequel_plugins}#{model_contents}").split("\n").map { |line| "  " * indent_depth + line } .join("\n") << "\n"
  inject_into_class(model_path, class_parts.last, content) if model_exists?
end
migration_data() click to toggle source
# File lib/sequel/devise/generators/devise_generator.rb, line 58
      def migration_data
<<RUBY
      ## Database authenticatable
      String :email,              :null => false, :default => ""
      String :encrypted_password, :null => false, :default => ""

      ## Recoverable
      String :reset_password_token
      String :reset_password_sent_at

      ## Rememberable
      DateTime :remember_created_at

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

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

      ## Lockable
      # Integer  :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
      # String   :unlock_token # Only if unlock strategy is :email or :both
      # DateTime :locked_at
RUBY
      end
sequel_plugins() click to toggle source
# File lib/sequel/devise/generators/devise_generator.rb, line 39
def sequel_plugins
  [
    ':devise', 
    ':timestamps, :update_on_create => true'
  ].map { |p| "  plugin #{p}\n" }.join('')
end