forest_liana 1.3.42 → 1.3.43
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 +4 -4
- data/app/controllers/forest_liana/resources_controller.rb +6 -6
- data/app/serializers/forest_liana/serializer_factory.rb +5 -1
- data/app/services/forest_liana/belongs_to_updater.rb +2 -7
- data/app/services/forest_liana/schema_adapter.rb +13 -10
- data/app/services/forest_liana/schema_utils.rb +1 -1
- data/lib/forest_liana.rb +2 -0
- data/lib/forest_liana/bootstraper.rb +7 -0
- data/lib/forest_liana/collection.rb +4 -2
- data/lib/forest_liana/version.rb +1 -1
- data/test/dummy/db/schema.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b0816d726c0204d712745f22efe4e1ab17a698c
|
4
|
+
data.tar.gz: bc3bd8651348a3ebdcb9305c1b6cd669fde86449
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be3ff96e743e23b126b10a715214ec5eaa5902b329c90e8078ef72e36ed4e819f7341652ad2ef17830d1dfe49e51c19b928ebf39a0063def1586640f19987fbc
|
7
|
+
data.tar.gz: 25ebe3f5446e5495a6bfc678835f6a27235fd42abfb6a3805516ff84ad4760536b5c17db43dbf7469cd7dca7dc8acdfada47f87eaa59091b53a289b3392754a6
|
@@ -26,19 +26,19 @@ module ForestLiana
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def create
|
29
|
-
|
30
|
-
|
29
|
+
creator = ResourceCreator.new(@resource, params)
|
30
|
+
creator.perform
|
31
31
|
|
32
32
|
render serializer: nil,
|
33
|
-
json: serialize_model(
|
33
|
+
json: serialize_model(creator.record, include: includes)
|
34
34
|
end
|
35
35
|
|
36
36
|
def update
|
37
|
-
|
38
|
-
|
37
|
+
updater = ResourceUpdater.new(@resource, params)
|
38
|
+
updater.perform
|
39
39
|
|
40
40
|
render serializer: nil,
|
41
|
-
json: serialize_model(
|
41
|
+
json: serialize_model(updater.record, include: includes)
|
42
42
|
end
|
43
43
|
|
44
44
|
def destroy
|
@@ -177,7 +177,11 @@ module ForestLiana
|
|
177
177
|
SchemaUtils.associations(active_record_class).each do |a|
|
178
178
|
serializer.send(serializer_association(a), a.name) {
|
179
179
|
if [:has_one, :belongs_to].include?(a.macro)
|
180
|
-
|
180
|
+
begin
|
181
|
+
object.send(a.name).try(:reload)
|
182
|
+
rescue ActiveRecord::RecordNotFound
|
183
|
+
nil
|
184
|
+
end
|
181
185
|
else
|
182
186
|
[]
|
183
187
|
end
|
@@ -9,13 +9,8 @@ module ForestLiana
|
|
9
9
|
|
10
10
|
def perform
|
11
11
|
@record = @resource.find(@params[:id])
|
12
|
-
|
13
|
-
|
14
|
-
new_value = @association.klass.find(@data[:id]) if @data && @data[:id]
|
15
|
-
@record.send("#{@association.name}=", new_value)
|
16
|
-
else
|
17
|
-
@record.send("#{@association.foreign_key}=", nil)
|
18
|
-
end
|
12
|
+
new_value = @association.klass.find(@data[:id]) if @data && @data[:id]
|
13
|
+
@record.send("#{@association.name}=", new_value)
|
19
14
|
|
20
15
|
@record.save()
|
21
16
|
end
|
@@ -212,26 +212,29 @@ module ForestLiana
|
|
212
212
|
|
213
213
|
case column.type
|
214
214
|
when :integer
|
215
|
-
'Number'
|
215
|
+
type = 'Number'
|
216
216
|
when :float
|
217
|
-
'Number'
|
217
|
+
type = 'Number'
|
218
218
|
when :decimal
|
219
|
-
'Number'
|
219
|
+
type = 'Number'
|
220
220
|
when :datetime
|
221
|
-
'Date'
|
221
|
+
type = 'Date'
|
222
222
|
when :date
|
223
|
-
'Date'
|
223
|
+
type = 'Date'
|
224
224
|
when :string
|
225
|
-
'String'
|
225
|
+
type = 'String'
|
226
226
|
when :text
|
227
|
-
'String'
|
227
|
+
type = 'String'
|
228
228
|
when :citext
|
229
|
-
'String'
|
229
|
+
type = 'String'
|
230
230
|
when :uuid
|
231
|
-
'String'
|
231
|
+
type = 'String'
|
232
232
|
when :boolean
|
233
|
-
'Boolean'
|
233
|
+
type = 'Boolean'
|
234
234
|
end
|
235
|
+
|
236
|
+
is_array = (column.respond_to?(:array) && column.array == true)
|
237
|
+
is_array ? [type] : type
|
235
238
|
end
|
236
239
|
|
237
240
|
def add_enum_values_if_is_enum(column_schema, column)
|
@@ -16,7 +16,7 @@ module ForestLiana
|
|
16
16
|
def self.find_model_from_table_name(table_name)
|
17
17
|
model = nil
|
18
18
|
|
19
|
-
|
19
|
+
ForestLiana.models.each do |subclass|
|
20
20
|
if subclass.abstract_class?
|
21
21
|
model = self.find_model_from_abstract_class(subclass, table_name)
|
22
22
|
elsif subclass.table_name == table_name
|
data/lib/forest_liana.rb
CHANGED
@@ -12,10 +12,12 @@ module ForestLiana
|
|
12
12
|
mattr_accessor :integrations
|
13
13
|
mattr_accessor :apimap
|
14
14
|
mattr_accessor :allowed_users
|
15
|
+
mattr_accessor :models
|
15
16
|
|
16
17
|
# Legacy.
|
17
18
|
mattr_accessor :jwt_signing_key
|
18
19
|
|
19
20
|
self.apimap = []
|
20
21
|
self.allowed_users = []
|
22
|
+
self.models = []
|
21
23
|
end
|
@@ -32,6 +32,7 @@ More info at: https://github.com/ForestAdmin/forest-rails/releases/tag/1.2.0"
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def perform
|
35
|
+
fetch_models
|
35
36
|
check_integrations_setup
|
36
37
|
create_serializers
|
37
38
|
|
@@ -44,6 +45,12 @@ More info at: https://github.com/ForestAdmin/forest-rails/releases/tag/1.2.0"
|
|
44
45
|
|
45
46
|
private
|
46
47
|
|
48
|
+
def fetch_models
|
49
|
+
ActiveRecord::Base.subclasses.each do |subclass|
|
50
|
+
ForestLiana.models << subclass
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
47
54
|
def cast_to_array value
|
48
55
|
value.is_a?(String) ? [value] : value
|
49
56
|
end
|
@@ -21,7 +21,8 @@ module ForestLiana::Collection
|
|
21
21
|
def field(name, opts, &block)
|
22
22
|
model.fields << opts.merge({ field: name, :'is-searchable' => false })
|
23
23
|
|
24
|
-
if serializer_name
|
24
|
+
if serializer_name && ForestLiana::UserSpace.const_defined?(
|
25
|
+
serializer_name)
|
25
26
|
ForestLiana::UserSpace.const_get(serializer_name).class_eval do
|
26
27
|
attribute(name, &block)
|
27
28
|
end
|
@@ -35,7 +36,8 @@ module ForestLiana::Collection
|
|
35
36
|
type: ['String']
|
36
37
|
})
|
37
38
|
|
38
|
-
if serializer_name
|
39
|
+
if serializer_name && ForestLiana::UserSpace.const_defined?(
|
40
|
+
serializer_name)
|
39
41
|
ForestLiana::UserSpace.const_get(serializer_name).class_eval do
|
40
42
|
has_many(name, name: name)
|
41
43
|
end
|
data/lib/forest_liana/version.rb
CHANGED
data/test/dummy/db/schema.rb
CHANGED
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: 1.3.
|
4
|
+
version: 1.3.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Munda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|