28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/didww/resource/exclusive_relationship.rb', line 28
def exclusive_relationships(mapping)
full_mapping = {}
mapping.each do |a, b|
full_mapping[a.to_s] = b.to_s
full_mapping[b.to_s] = a.to_s
end
full_mapping.freeze
define_method(:_exclusive_relationship_mapping) { full_mapping }
define_method(:relationships) do
@relationships ||= Relations.new(self.class, {}, full_mapping)
end
define_method(:relationships=) do |rels|
attrs = case rels
when JsonApiClient::Relationships::Relations then rels.attributes
when Hash then rels
else rels || {}
end
@relationships = Relations.new(self.class, attrs, full_mapping)
end
end
|