Sha256: 3079152d5021c6c4a28e7771f7ccdc4cab64281d8f17d0fbffcf88908537bf94

Contents?: true

Size: 854 Bytes

Versions: 3

Compression:

Stored size: 854 Bytes

Contents

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dm-devise-1.1.1 lib/devise/orm/data_mapper/schema.rb
dm-devise-1.1.0 lib/devise/orm/data_mapper/schema.rb
dm-devise-0.1.0 lib/devise/orm/data_mapper/schema.rb