lib/blind_index/model.rb in blind_index-0.2.0 vs lib/blind_index/model.rb in blind_index-0.2.1
- old
+ new
@@ -24,11 +24,15 @@
attribute: attribute,
expression: expression,
bidx_attribute: bidx_attribute
}
+ define_singleton_method method_name do |value|
+ BlindIndex.generate_bidx(value, blind_indexes[name])
+ end
+
define_method method_name do
- self.send("#{bidx_attribute}=", BlindIndex.generate_bidx(send(attribute), self.class.blind_indexes[name]))
+ self.send("#{bidx_attribute}=", self.class.send(method_name, send(attribute)))
end
if callback
before_validation method_name, if: -> { changes.key?(attribute.to_s) }
end