12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/messaging/message/copy.rb', line 12
def copy(source, receiver=nil, copy: nil, include: nil, exclude: nil, metadata: nil, strict: nil)
metadata ||= false
strict ||= false
if receiver.nil?
receiver = self
end
if receiver.class == Class
receiver = receiver.build
end
if copy.nil? && include.nil?
include = source.class.attribute_names
end
begin
SetAttributes.(receiver, source, copy: copy, include: include, exclude: exclude, strict: strict)
rescue SetAttributes::Assign::Error => e
raise Error, e.message, e.backtrace
end
if metadata
metadata_include = source.metadata.class.attribute_names - [:properties, :local_properties]
SetAttributes.(receiver.metadata, source.metadata, include: metadata_include)
receiver.metadata.properties = source.metadata.properties.dup
receiver.metadata.local_properties = source.metadata.local_properties.dup
end
receiver
end
|