datory 1.0.0.rc17 → 1.0.0.rc19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff1061ed5efc8ae9bb2b2869d8c745de7576adbb85758c1ed0655f6159e0e191
4
- data.tar.gz: e0040ac246130dd097433a3f472b94dcf6022ce334ba8213af31336d87fdbcd7
3
+ metadata.gz: 3de83481e2e67d0aa3e0bc5eafaa1172f272cdbb27402d2201388839845b6a6c
4
+ data.tar.gz: db131a7480b6f328d021303c13f6fb6b5f42a5b975739d8b86424a9deab67ed6
5
5
  SHA512:
6
- metadata.gz: b38dbd31412aa31012c51b6e9fda0efa2a5bbabb946904491670127c69965d20c8e6e962c8666259e64a25a47bf89e3464d457600dfa7bbff152bf6b237e5b18
7
- data.tar.gz: 50310262dfe8d781cb869091fdcbadac1da85a8c3769b1988f8465786919861fe151ecc6299667b19ae7733cd269ab61d89831ef19c38dfe40fb2bbf141628b1
6
+ metadata.gz: 53d520aaf3d7e4069a9e4c6f670b6863f7f2b68cc9562a987f5e6d5c376a25056b4e6b4d961da030da429165b7e76afb5eda60eea7ed8a5ab9f1e73bd02ba856
7
+ data.tar.gz: 2f8427553e16cea1a634851c8717fe9f9f41089aa55d04af9bd62efe7f7a040e25b52fee26bbf29e662d3f8043cde4060a1fea0e46cddfbbdca56bf5b9fda412
@@ -47,34 +47,38 @@ module Datory
47
47
  ########################################################################
48
48
 
49
49
  def uuid(name, **options)
50
+ options = options.slice(:to)
50
51
  options = options.merge(format: :uuid)
51
52
  string(name, **options)
52
53
  end
53
54
 
54
55
  def money(name, **options)
55
- options_for_cents = options.merge(from: Integer)
56
- options_for_currency = options.merge(from: [Symbol, String])
56
+ options = options.slice(:to)
57
57
 
58
- attribute(:"#{name}_cents", **options_for_cents)
59
- attribute(:"#{name}_currency", **options_for_currency)
58
+ integer :"#{name}_cents", **options
59
+ string :"#{name}_currency", **options
60
60
  end
61
61
 
62
62
  def duration(name, **options)
63
+ options = options.slice(:to)
63
64
  options = options.merge(from: String, as: ActiveSupport::Duration, format: { from: :duration })
64
65
  string(name, **options)
65
66
  end
66
67
 
67
68
  def date(name, **options)
69
+ options = options.slice(:to)
68
70
  options = options.merge(from: String, as: Date, format: { from: :date })
69
71
  string(name, **options)
70
72
  end
71
73
 
72
74
  def time(name, **options)
75
+ options = options.slice(:to)
73
76
  options = options.merge(from: String, as: Time, format: { from: :time })
74
77
  string(name, **options)
75
78
  end
76
79
 
77
80
  def datetime(name, **options)
81
+ options = options.slice(:to)
78
82
  options = options.merge(from: String, as: DateTime, format: { from: :datetime })
79
83
  string(name, **options)
80
84
  end
@@ -96,6 +100,11 @@ module Datory
96
100
  attribute(name, **options)
97
101
  end
98
102
 
103
+ def boolean(name, **options)
104
+ options = options.merge(from: [TrueClass, FalseClass])
105
+ attribute(name, **options)
106
+ end
107
+
99
108
  ########################################################################
100
109
 
101
110
  def collection_of_attributes
@@ -24,15 +24,17 @@ module Datory
24
24
  end
25
25
 
26
26
  def deserialize(json) # rubocop:disable Metrics/MethodLength
27
- if [Set, Array].include?(json.class)
28
- json.map do |json_item|
29
- deserialize(json_item)
27
+ # TODO: Need to improve this place by adding more checks and an error exception.
28
+ parsed_data = json.is_a?(String) ? JSON.parse(json) : json
29
+
30
+ if [Set, Array].include?(parsed_data.class)
31
+ parsed_data.map do |item|
32
+ deserialize(item)
30
33
  end
31
34
  else
32
35
  context = send(:new)
33
- hash = JSON.parse(json.to_json)
34
36
 
35
- _deserialize(context, **hash)
37
+ _deserialize(context, **parsed_data)
36
38
  end
37
39
  rescue Datory::Service::Exceptions::Input,
38
40
  Datory::Service::Exceptions::Internal,
@@ -5,7 +5,7 @@ module Datory
5
5
  MAJOR = 1
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = "rc17"
8
+ PRE = "rc19"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc17
4
+ version: 1.0.0.rc19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-01 00:00:00.000000000 Z
11
+ date: 2024-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport