Sha256: 0f69f2d6a9c94665786da0f7035d68badd019dcc2e5bfbf103cc144636178d63

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

module Devise
  module Orm
    module Neo4j
      module Schema
        include Devise::Schema

        INDEXED_PROPERTIES = [ :email, :authentication_token, :confirmation_token, :remember_token, :reset_password_token, :unlock_token ]
  
        # Tell how to apply schema methods
        def apply_devise_schema(name, type, options={})
          index name, :type => :exact if INDEXED_PROPERTIES.include?(name)
          create_property(name, type, options)
        end
        
        protected
        def create_property(name, type, options)
          # Hack to get around encrypted_password not having the default of ""
          options.delete(:default) if name == :encrypted_password
          
          # If the property is required, its presence should be checked anyway
          options.delete(:null)
          
          Rails.logger.debug "Adding Devise property for #{self}: #{name.inspect}, #{{ :type => map_type(type) }.merge!(options).inspect}"
          property name, { :type => map_type(type) }.merge!(options)
        end

        # map the Java type to the right Ruby type
        def map_type(type)
          case type.to_s
          when "DateTime"
            Time
          when "Integer"
            Fixnum
          else 
            type
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise-neo4j-1.0.2 lib/devise/orm/neo4j/schema.rb
devise-neo4j-1.0.1 lib/devise/orm/neo4j/schema.rb
devise-neo4j-1.0.0 lib/devise/orm/neo4j/schema.rb