mini_serializer 0.1.2 → 0.1.3
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/lib/mini_serializer/version.rb +1 -1
- data/lib/mini_serializer.rb +24 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0f16b1f10c164ddf95056145d8fd53359a2e1c8ffe069e1c18be84f267c789a
|
4
|
+
data.tar.gz: 194dca15bb92700ca6639185f4bf5d551f21786d0d7a1c3ff2b344d149090e66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5483b81bb927ec4b5fa16598b7b49b3414873b8a44d3fcede718ea827dbe56ad0b6e4bae0649d92dcfca3f5b59a61ae02305ccfd26cbc38b710b482e5acc9f15
|
7
|
+
data.tar.gz: 873ea28c3e62ef52b17d80b22a5585d8037a7fbd1ed35b93f20b1613bbbc8dbc26a8728f7ad512b0b80db0accce10505dcd4116a41dcedb666402ab35782796d
|
data/lib/mini_serializer.rb
CHANGED
@@ -20,12 +20,17 @@ module MiniSerializer
|
|
20
20
|
wams_has_one<<[object,except_methods]
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def get_params_included_to_json(with_except:false)
|
24
|
+
fetch_association_objects
|
25
|
+
if with_except
|
26
|
+
{include:wams_association_for_to_json,except:wams_except_params_main_object}
|
27
|
+
else
|
28
|
+
{include:wams_association_for_to_json}
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
|
-
def json_serializer
|
28
|
-
included_data=
|
32
|
+
def json_serializer(object=nil)
|
33
|
+
included_data=includes_to_serializer
|
29
34
|
var_hash={}
|
30
35
|
|
31
36
|
wams_has_many.map do |object_assosiation,except_params|
|
@@ -36,19 +41,31 @@ module MiniSerializer
|
|
36
41
|
end
|
37
42
|
|
38
43
|
if wams_except_params_main_object.any? # have except params for main object
|
39
|
-
|
44
|
+
unless object.nil?
|
45
|
+
object.to_json({include:wams_association_for_to_json,except:wams_except_params_main_object})
|
46
|
+
else
|
47
|
+
included_data.to_json({include:wams_association_for_to_json,except:wams_except_params_main_object})
|
48
|
+
end
|
40
49
|
else
|
41
|
-
|
50
|
+
unless object.nil?
|
51
|
+
return object.to_json({include:wams_association_for_to_json})
|
52
|
+
else
|
53
|
+
return included_data.to_json({include:wams_association_for_to_json})
|
54
|
+
end
|
42
55
|
end
|
43
56
|
# example output : wams_association_for_to_json is {'house_images':{except: [:id,:house_id]} }
|
44
57
|
end
|
45
58
|
|
59
|
+
def get_object_included
|
60
|
+
return includes_to_serializer
|
61
|
+
end
|
62
|
+
|
46
63
|
private
|
47
64
|
attr_accessor :wams_has_many,:wams_has_one ,:wams_association_object,
|
48
65
|
:wams_except_params,:wams_main_object,:wams_association_for_to_json,
|
49
66
|
:wams_except_params_main_object
|
50
67
|
|
51
|
-
def
|
68
|
+
def includes_to_serializer
|
52
69
|
data_with_includes=nil
|
53
70
|
fetch_association_objects
|
54
71
|
if wams_has_many.any?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mahdi alizadeh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|