Sha256: 9af2e794fe8988490ed8208ce832bbf4b33eaeaf34cb9c16215d5ca8486b9266

Contents?: true

Size: 634 Bytes

Versions: 15

Compression:

Stored size: 634 Bytes

Contents

require 'ardm/property/string'
require 'bcrypt'

module Ardm
  class Property
    class BCryptHash < String
      load_as BCrypt::Password

      length 60

      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

      def dump(value)
        load(value)
      end

      def typecast(value)
        load(value)
      end

    end # class BCryptHash
  end # class Property
end # module Ardm

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ardm-0.4.0.ar427 lib/ardm/property/bcrypt_hash.rb
ardm-0.4.0 lib/ardm/property/bcrypt_hash.rb
ardm-0.3.2 lib/ardm/property/bcrypt_hash.rb
ardm-0.3.1 lib/ardm/property/bcrypt_hash.rb
ardm-0.3.0 lib/ardm/property/bcrypt_hash.rb
ardm-0.2.7 lib/ardm/property/bcrypt_hash.rb
ardm-0.2.6 lib/ardm/property/bcrypt_hash.rb
ardm-0.2.5 lib/ardm/property/bcrypt_hash.rb
ardm-0.2.4 lib/ardm/property/bcrypt_hash.rb
ardm-0.2.3 lib/ardm/property/bcrypt_hash.rb
ardm-0.2.2 lib/ardm/property/bcrypt_hash.rb
ardm-0.2.1 lib/ardm/property/bcrypt_hash.rb
ardm-0.2.0 lib/ardm/property/bcrypt_hash.rb
ardm-0.1.0 lib/ardm/property/bcrypt_hash.rb
ardm-0.0.1 lib/ardm/property/bcrypt_hash.rb