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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ae7f0c8a6441cc111cfd8600e62ae4a12fb0f2de39fc84e5a900e65acc1d19d
4
- data.tar.gz: 9e4cba67412bf2d726e29fa5f005b319bd9ebc5774a33e5014cf226544f82c2d
3
+ metadata.gz: e0f16b1f10c164ddf95056145d8fd53359a2e1c8ffe069e1c18be84f267c789a
4
+ data.tar.gz: 194dca15bb92700ca6639185f4bf5d551f21786d0d7a1c3ff2b344d149090e66
5
5
  SHA512:
6
- metadata.gz: 890ef002815bf0d2f6df848b420b005faf77076dbf8e72cc0a6f259df32f8373db143559bfc217ef9dad30cbfcc9b7eed6598ff53b4f15cfc0f71321e6eb21b9
7
- data.tar.gz: 65cf5c7925ac087d114b43ed28a9befff33692be3a6692e5c34c343001c8772a035683ad1aed7e6b8fd23c34dabdb70e29c55ad92bd5773c9203a35cddfdc266
6
+ metadata.gz: 5483b81bb927ec4b5fa16598b7b49b3414873b8a44d3fcede718ea827dbe56ad0b6e4bae0649d92dcfca3f5b59a61ae02305ccfd26cbc38b710b482e5acc9f15
7
+ data.tar.gz: 873ea28c3e62ef52b17d80b22a5585d8037a7fbd1ed35b93f20b1613bbbc8dbc26a8728f7ad512b0b80db0accce10505dcd4116a41dcedb666402ab35782796d
@@ -1,3 +1,3 @@
1
1
  module MiniSerializer
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.3".freeze
3
3
  end
@@ -20,12 +20,17 @@ module MiniSerializer
20
20
  wams_has_one<<[object,except_methods]
21
21
  end
22
22
 
23
- def get_included_objects
24
- return wams_association_object
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=includes_to_serlizer
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
- return included_data.to_json({include:wams_association_for_to_json,except:wams_except_params_main_object})
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
- return included_data.to_json({include:wams_association_for_to_json})
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 includes_to_serlizer
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.2
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-09-26 00:00:00.000000000 Z
11
+ date: 2018-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler