Class: DataMapper::Types::BCryptHash
Constant Summary
DataMapper::Type::PROPERTY_OPTIONS, DataMapper::Type::PROPERTY_OPTION_ALIASES
Class Method Summary
collapse
bind, configure, inherited, options, primitive
Class Method Details
.dump(value, property) ⇒ Object
16
17
18
|
# File 'lib/gems/dm-types-0.9.9/lib/dm-types/bcrypt_hash.rb', line 16
def self.dump(value, property)
typecast(value, property)
end
|
.load(value, property) ⇒ Object
12
13
14
|
# File 'lib/gems/dm-types-0.9.9/lib/dm-types/bcrypt_hash.rb', line 12
def self.load(value, property)
typecast(value, property)
end
|
.typecast(value, property) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/gems/dm-types-0.9.9/lib/dm-types/bcrypt_hash.rb', line 20
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
|