lib/blind_index/model.rb in blind_index-2.2.0 vs lib/blind_index/model.rb in blind_index-2.3.0
- old
+ new
@@ -34,10 +34,18 @@
key = options[:key]
key ||= -> { BlindIndex.index_key(table: try(:table_name) || collection_name.to_s, bidx_attribute: bidx_attribute, master_key: options[:master_key], encode: false) }
class_eval do
+ activerecord = defined?(ActiveRecord) && self < ActiveRecord::Base
+
+ if activerecord && ActiveRecord::VERSION::MAJOR >= 6
+ # blind index value isn't really sensitive
+ # but don't need to show it in the Rails console
+ self.filter_attributes += [/\A#{Regexp.escape(bidx_attribute)}\z/]
+ end
+
@blind_indexes ||= {}
unless respond_to?(:blind_indexes)
def self.blind_indexes
parent_indexes =
@@ -67,11 +75,9 @@
define_method method_name do
send("#{bidx_attribute}=", self.class.send(class_method_name, send(attribute)))
end
if callback
- activerecord = defined?(ActiveRecord) && self < ActiveRecord::Base
-
# TODO reuse module
m = Module.new do
define_method "#{attribute}=" do |value|
result = super(value)
send(method_name)