7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/imperator/mongoid/attribute_helper.rb', line 7
def attributes_for clazz, options = {}
use_attributes = clazz.attribute_names
unless options[:except].blank?
use_attributes = use_attributes - [options[:except]].flatten.map(&:to_s)
end
unless options[:only].blank?
use_attributes = use_attributes & [options[:only]].flatten.map(&:to_s) end
clazz.fields.each do |key, field|
name = key
type = field.type
next unless use_attributes.include? name.to_s
attribute field.name, field.type, :default => field.default_val
end
end
|