forest_liana 9.15.1 → 9.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d472c9569d143414f26b2f574fb1a645eabb4cae94ada16510ea776609d78e7
|
4
|
+
data.tar.gz: d5ec3a959fea0e578abdd8667ec2c062e125aa663e241b27834ad668effa74c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e804289358deb668cab2b0dcd23027a18b0cc67fa27a490ae7cb405ef62c29a269df58f6d9692651782dce51c41ae09dcbf692686cdeea8dc4e0f22165a37334
|
7
|
+
data.tar.gz: 4ff713e235b574d038af42d11f6e84c6e56a9cca6dfd738f432cf16259a64cd8a1059b97f4923a0304b19b2f1cea15cb32d066c868889494b9f16d38ebe69c33
|
@@ -131,33 +131,6 @@ module ForestLiana
|
|
131
131
|
ret
|
132
132
|
end
|
133
133
|
|
134
|
-
def has_one_relationships
|
135
|
-
return {} if self.class.to_one_associations.nil?
|
136
|
-
data = {}
|
137
|
-
self.class.to_one_associations.each do |attribute_name, attr_data|
|
138
|
-
relation = object.class.reflect_on_all_associations.find { |a| a.name == attribute_name }
|
139
|
-
|
140
|
-
next if !should_include_attr?(attribute_name, attr_data)
|
141
|
-
|
142
|
-
unless relation.nil? || (relation.respond_to?(:polymorphic?) && relation.polymorphic?)
|
143
|
-
relation_class_name = ForestLiana.name_for(relation.klass).demodulize
|
144
|
-
|
145
|
-
if object.respond_to?(relation.foreign_key.to_sym) &&
|
146
|
-
@options[:fields][relation_class_name]&.size == 1 &&
|
147
|
-
@options[:fields][relation_class_name]&.include?(relation.klass.primary_key.to_sym)
|
148
|
-
|
149
|
-
attr_data[:attr_or_block] = proc {
|
150
|
-
foreign_key_value = object.send(relation.foreign_key.to_sym)
|
151
|
-
foreign_key_value.nil? ? nil : relation.klass.new(relation.klass.primary_key => foreign_key_value)
|
152
|
-
}
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
data[attribute_name] = attr_data
|
157
|
-
end
|
158
|
-
data
|
159
|
-
end
|
160
|
-
|
161
134
|
private
|
162
135
|
|
163
136
|
def intercom_integration?
|
data/lib/forest_liana/version.rb
CHANGED
@@ -5,27 +5,6 @@ module ForestLiana
|
|
5
5
|
let(:island) { Island.create!(name: 'TestIsland') }
|
6
6
|
let(:tree) { Tree.create!(name: 'TestTree', island: island, owner: user) }
|
7
7
|
|
8
|
-
it 'simulates has_one relation with only primary key' do
|
9
|
-
factory = described_class.new
|
10
|
-
serializer_class = factory.serializer_for(Tree)
|
11
|
-
|
12
|
-
serializer_class.send(:has_one, :island) { }
|
13
|
-
|
14
|
-
instance = serializer_class.new(tree, fields: {
|
15
|
-
'Island' => [:id],
|
16
|
-
'Tree' => [:island]
|
17
|
-
})
|
18
|
-
|
19
|
-
relationships = instance.send(:has_one_relationships)
|
20
|
-
expect(relationships).to have_key(:island)
|
21
|
-
relation_data = relationships[:island]
|
22
|
-
expect(relation_data[:attr_or_block]).to be_a(Proc)
|
23
|
-
model = relation_data[:attr_or_block].call
|
24
|
-
|
25
|
-
expect(model).to be_a(Island)
|
26
|
-
expect(model.id).to eq(island.id)
|
27
|
-
end
|
28
|
-
|
29
8
|
it 'returns nil if foreign key is nil' do
|
30
9
|
tree_without_island = Tree.create!(name: 'NoIslandTree', island_id: nil, owner: user)
|
31
10
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_liana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.15.
|
4
|
+
version: 9.15.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Munda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-07-
|
11
|
+
date: 2025-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|