forest_liana 1.3.41 → 1.3.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/forest_liana/associations_controller.rb +1 -1
- data/app/controllers/forest_liana/resources_controller.rb +1 -1
- data/app/deserializers/forest_liana/resource_deserializer.rb +34 -1
- data/app/services/forest_liana/resource_creator.rb +1 -1
- data/app/services/forest_liana/resource_updater.rb +1 -1
- data/lib/forest_liana/version.rb +1 -1
- 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: cb3568d5560fd7e5f2bed09463aeabd25cdcf507
|
4
|
+
data.tar.gz: d08fed354b6e2ec24643975b1611df742f416307
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27ab72a652bc72f34efaff24b2853c0440879f86cf506f6cbd811fceba3b6f6d076d2b2a839501a0d5feef2b6eaebab478be8b0f2c5af3c26bad7dc28f96ebea
|
7
|
+
data.tar.gz: 630815abbb6a8ef6b6f2dc0510345fac00b65730afde352ae65507034ce5ceff98cb880ae9541a8ea768985cc0a73943b38730ec8fe8d7309552e3bba9be77be
|
@@ -3,13 +3,15 @@ require_relative '../../../lib/forest_liana/base64_string_io'
|
|
3
3
|
module ForestLiana
|
4
4
|
class ResourceDeserializer
|
5
5
|
|
6
|
-
def initialize(resource, params)
|
6
|
+
def initialize(resource, params, with_relationships)
|
7
7
|
@params = params.permit! if params.respond_to?(:permit!)
|
8
8
|
@resource = resource
|
9
|
+
@with_relationships = with_relationships
|
9
10
|
end
|
10
11
|
|
11
12
|
def perform
|
12
13
|
@attributes = extract_attributes
|
14
|
+
extract_relationships if @with_relationships
|
13
15
|
extract_paperclip
|
14
16
|
extract_carrierwave
|
15
17
|
extract_acts_as_taggable
|
@@ -25,6 +27,37 @@ module ForestLiana
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
30
|
+
def extract_relationships
|
31
|
+
if @params['data']['relationships']
|
32
|
+
@params['data']['relationships'].each do |name, relationship|
|
33
|
+
data = relationship['data']
|
34
|
+
# Rails 3 requires a :sym argument for the reflect_on_association
|
35
|
+
# call.
|
36
|
+
association = @resource.reflect_on_association(name.try(:to_sym))
|
37
|
+
|
38
|
+
if [:has_one, :belongs_to].include?(association.try(:macro))
|
39
|
+
# TODO: refactor like this?
|
40
|
+
#if data.blank?
|
41
|
+
#@attributes[name] = nil
|
42
|
+
#else
|
43
|
+
#@attributes[name] = association.klass.find(data[:id])
|
44
|
+
#end
|
45
|
+
|
46
|
+
# ActionController::Parameters do not inherit from Hash anymore
|
47
|
+
# since Rails 5.
|
48
|
+
if (data.is_a?(Hash) || data.is_a?(ActionController::Parameters)) && data[:id]
|
49
|
+
@attributes[name] = association.klass.find(data[:id])
|
50
|
+
elsif data.blank?
|
51
|
+
@attributes[name] = nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Strong parameter permit all new relationships attributes.
|
57
|
+
@attributes = @attributes.permit! if @attributes.respond_to?(:permit!)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
28
61
|
def extract_paperclip
|
29
62
|
return unless @resource.respond_to?(:attachment_definitions)
|
30
63
|
|
data/lib/forest_liana/version.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.42
|
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-
|
11
|
+
date: 2016-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|