Sha256: 7ad6a7a48d38525c0f138a04388779f8dc159db237e70d4c8d0f410fe1168864
Contents?: true
Size: 763 Bytes
Versions: 5
Compression:
Stored size: 763 Bytes
Contents
require 'rubygems' gem 'bcrypt-ruby', '~>2.0.3' require 'bcrypt' module DataMapper module Types class BCryptHash < DataMapper::Type primitive String size 60 def self.load(value, property) typecast(value, property) end def self.dump(value, property) typecast(value, property) end def self.typecast(value, property) if value.nil? nil else begin value.is_a?(BCrypt::Password) ? value : BCrypt::Password.new(value) rescue BCrypt::Errors::InvalidHash BCrypt::Password.create(value, :cost => BCrypt::Engine::DEFAULT_COST) end end end end # class BCryptHash end # module Types end # module DataMapper
Version data entries
5 entries across 5 versions & 2 rubygems