11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/denormalized.rb', line 11
def denormalized(*attributes)
options = attributes..dup
if attributes.empty?
raise ArgumentError, 'You need to supply at least one column'
end
if options.empty? || options[:tables]&.empty?
raise ArgumentError, 'You need to supply at least one table'
end
class_attribute :denormalized_configuration
self.denormalized_configuration = {
columns: attributes,
tables: options[:tables],
columns_hash: Hash[attributes.map { |column| [column, true] }]
}
include Denormalized::Core unless denormalized?
end
|