Module: Devise::Orm::MongoMapper::Schema
- Includes:
- Schema
- Defined in:
- lib/devise/orm/mongo_mapper/schema.rb
Constant Summary collapse
- SCHEMA_OPTIONS =
{ :null => :required, :limit => :length }
Instance Method Summary collapse
-
#apply_devise_schema(name, type, options = {}) ⇒ Object
Tell how to apply schema methods.
Instance Method Details
#apply_devise_schema(name, type, options = {}) ⇒ Object
Tell how to apply schema methods. This automatically maps :limit to :length and :null to :required.
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 |
# File 'lib/devise/orm/mongo_mapper/schema.rb', line 27 def apply_devise_schema(name, type, ={}) SCHEMA_OPTIONS.each do |old_key, new_key| next unless .key?(old_key) if :null == old_key # :required is opposite of :null [new_key] = !.delete(old_key) else [new_key] = .delete(old_key) end end .delete(:default) if [:default].nil? required_option = .delete(:required) length_option = .delete(:length) type = Time if type == DateTime key name, type, counter = ::MongoMapper::ValidationUtil.inc_counter handle_email(name, counter) if name == :email handle_length(name, counter, length_option) if length_option handle_required(name, counter) if required_option end |