Method: DataMapper::Property::BCryptHash#load

Defined in:
lib/dm-types/bcrypt_hash.rb

#load(value) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/dm-types/bcrypt_hash.rb', line 14

def load(value)
  unless value.nil?
    begin
      primitive?(value) ? value : BCrypt::Password.new(value)
    rescue BCrypt::Errors::InvalidHash
      BCrypt::Password.create(value, :cost => BCrypt::Engine::DEFAULT_COST)
    end
  end
end