lib/blind_index.rb in blind_index-0.1.0 vs lib/blind_index.rb in blind_index-0.1.1

- old
+ new

@@ -1,17 +1,18 @@ # dependencies require "active_support" # modules -require "blind_index/extensions" require "blind_index/model" require "blind_index/version" module BlindIndex - class Error; end + class Error < StandardError; end def self.generate_bidx(value, key:, iterations:, expression: nil, **options) + key = key.call if key.respond_to?(:call) + raise BlindIndex::Error, "Missing key for blind index" unless key # apply expression value = expression.call(value) if expression @@ -23,11 +24,13 @@ [value].pack("m") end end ActiveSupport.on_load(:active_record) do + require "blind_index/extensions" extend BlindIndex::Model ActiveRecord::TableMetadata.prepend(BlindIndex::Extensions::TableMetadata) - if ActiveRecord::VERSION::STRING.start_with?("5.0.") + + unless ActiveRecord::VERSION::STRING.start_with?("5.1.") ActiveRecord::Validations::UniquenessValidator.prepend(BlindIndex::Extensions::UniquenessValidator) end end