24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/normatron/extensions/active_record.rb', line 24
def normalize(*args)
options = args.
filters, columns = args.map(&:to_s), column_names
raise UnknownAttributeError if (columns & filters).size != filters.size
if options[:with].nil? || options[:with].blank?
new_filters = Normatron.config.default_filters
else
new_filters = Normatron.build_hash(options[:with])
end
@normalize_rules ||= {}
@normalize_rules =
args.reduce(@normalize_rules) do |hash, att|
filters = (@normalize_rules[att] || {}).merge(new_filters)
hash.merge({att => filters})
end
end
|