Sha256: a3cc3116933b187ee0e8d181dc6cba8aae6947c1627daad235b824ae78a5f00b
Contents?: true
Size: 1.02 KB
Versions: 4
Compression:
Stored size: 1.02 KB
Contents
require 'dm-devise' require 'devise/schema' module Devise module Orm module DataMapper module Schema include Devise::Schema SCHEMA_OPTIONS = { :null => :required, :limit => :length } # Tell how to apply schema methods. This automatically maps :limit to # :length and :null to :required. def apply_devise_schema(name, type, options={}) 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 end end end end
Version data entries
4 entries across 4 versions & 1 rubygems