Class: DataMapper::Property::BCryptHash

Inherits:
String
  • Object
show all
Defined in:
lib/dm-types/bcrypt_hash.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) dump(value)



21
22
23
# File 'lib/dm-types/bcrypt_hash.rb', line 21

def dump(value)
  load(value)
end

- (Object) load(value)



11
12
13
14
15
16
17
18
19
# File 'lib/dm-types/bcrypt_hash.rb', line 11

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

- (Object) typecast(value)



25
26
27
# File 'lib/dm-types/bcrypt_hash.rb', line 25

def typecast(value)
  load(value)
end