10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/mongoid-denormalize.rb', line 10
def denormalize(*args)
*fields, options = args
unless options.is_a?(Hash) && options[:from]
raise ArgumentError, 'Option :from is needed (e.g. denormalize :name, from: :user).'
end
fields = Mongoid::Denormalize.get_fields_with_names(self, fields, options)
fields.each { |field| field field[:as], type: field[:type] }
Mongoid::Denormalize.add_hook_to_child(self, fields, options)
Mongoid::Denormalize.add_hook_to_parent(self, fields, options)
end
|