Sha256: 881b77a1ec2998d1ac56aaac76c2d441f80b2e5aff86da375bf669545a9e1a8a
Contents?: true
Size: 719 Bytes
Versions: 3
Compression:
Stored size: 719 Bytes
Contents
require 'bcrypt' module DataMapper module Types class BCryptHash < DataMapper::Type primitive String length 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dm-types-0.10.2 | lib/dm-types/bcrypt_hash.rb |
dm-types-0.10.1 | lib/dm-types/bcrypt_hash.rb |
dm-types-0.10.0 | lib/dm-types/bcrypt_hash.rb |