module Devise::Orm::DataMapper::Schema

Constants

SCHEMA_OPTIONS

Public Instance Methods

apply_devise_schema(name, type, options={}) click to toggle source

Tell how to apply schema methods. This automatically maps :limit to :length and :null to :required.

# File lib/devise/orm/data_mapper/schema.rb, line 17
def apply_devise_schema(name, type, options={})
  return false if properties[name]
  SCHEMA_OPTIONS.each do |old_key, new_key|
    next unless options.key?(old_key)
    if :null == old_key
      # :required is opposite of :null
      options[new_key] = !options.delete(old_key)
    else
      options[new_key] = options.delete(old_key)
    end
  end

  if String == type && !options[:length]
    options[:length] = 255
  end
  
  options[:required] ||= false

  options.delete(:default) if options[:default].nil?
  property name, type, options
end