Module: Bushido::Schema
- Included in:
- Orm::ActiveRecord::Schema, Orm::Mongoid::Schema
- Defined in:
- lib/bushido/schema.rb
Overview
Holds devise schema information. To use it, just include its methods and overwrite the apply_schema method.
Instance Method Summary collapse
-
#apply_devise_schema(name, type, options = {}) ⇒ Object
Overwrite with specific modification to create your own schema.
-
#recoverable(options = {}) ⇒ Object
Creates reset_password_token and reset_password_sent_at.
-
#rememberable(options = {}) ⇒ Object
Creates remember_token and remember_created_at.
-
#trackable ⇒ Object
Creates sign_in_count, current_sign_in_at, last_sign_in_at, current_sign_in_ip, last_sign_in_ip.
Instance Method Details
#apply_devise_schema(name, type, options = {}) ⇒ Object
Overwrite with specific modification to create your own schema.
38 39 40 |
# File 'lib/bushido/schema.rb', line 38 def apply_devise_schema(name, type, ={}) raise NotImplementedError end |
#recoverable(options = {}) ⇒ Object
Creates reset_password_token and reset_password_sent_at.
Options
-
:reset_within - When true, adds a column that reset passwords within some date
10 11 12 13 14 |
# File 'lib/bushido/schema.rb', line 10 def recoverable(={}) use_within = .fetch(:reset_within, Devise.reset_password_within.present?) apply_devise_schema :reset_password_token, String apply_devise_schema :reset_password_sent_at, DateTime if use_within end |
#rememberable(options = {}) ⇒ Object
Creates remember_token and remember_created_at.
Options
-
:use_salt - When true, does not create a remember_token and use password_salt instead.
20 21 22 23 24 |
# File 'lib/bushido/schema.rb', line 20 def rememberable(={}) use_salt = .fetch(:use_salt, Devise.use_salt_as_remember_token) apply_devise_schema :remember_token, String unless use_salt apply_devise_schema :remember_created_at, DateTime end |
#trackable ⇒ Object
Creates sign_in_count, current_sign_in_at, last_sign_in_at, current_sign_in_ip, last_sign_in_ip.
28 29 30 31 32 33 34 |
# File 'lib/bushido/schema.rb', line 28 def trackable apply_devise_schema :sign_in_count, Integer, :default => 0 apply_devise_schema :current_sign_in_at, DateTime apply_devise_schema :last_sign_in_at, DateTime apply_devise_schema :current_sign_in_ip, String apply_devise_schema :last_sign_in_ip, String end |