Sha256: 3e75bfebe92fed3db993a4554b981be0603d2e879dea7fec2e7d0adb516cb6ca
Contents?: true
Size: 634 Bytes
Versions: 2
Compression:
Stored size: 634 Bytes
Contents
require_relative 'attr_similar/similarity_matching' require_relative 'attr_similar/version' module AttrSimilar extend ActiveSupport::Concern module ClassMethods def attr_similar(threshold_or_thresholds, *attributes) if threshold_or_thresholds.is_a?(Array) && threshold_or_thresholds.size != attributes.size raise 'Threshold count must equal number of attributes' end define_method :find_first_similar do |scope| AttrSimilar::SimilarityMatching.find_first_similar(scope, self, threshold_or_thresholds, attributes) end end end end ActiveRecord::Base.send :include, AttrSimilar
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
attr_similar-0.0.2 | lib/attr_similar.rb |
attr_similar-0.0.1 | lib/attr_similar.rb |