8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/activerecord-postgres-array/activerecord.rb', line 8
def arel_attributes_values(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
attrs = {}
klass = self.class
arel_table = klass.arel_table
attribute_names.each do |name|
if (column = column_for_attribute(name)) && (include_primary_key || !column.primary)
if include_readonly_attributes || !self.class.readonly_attributes.include?(name)
value = read_attribute(name)
if column.type.to_s =~ /_array$/ && value && value.is_a?(Array)
value = "'#{value.to_postgres_array(new_record?)}'"
elsif klass.serialized_attributes.include?(name)
value = @attributes[name].serialized_value
end
attrs[arel_table[name]] = value
end
end
end
attrs
end
|