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 +4 -4
- data/lib/datory/attributes/dsl.rb +13 -4
- data/lib/datory/context/callable.rb +7 -5
- data/lib/datory/version.rb +1 -1
- 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: 3de83481e2e67d0aa3e0bc5eafaa1172f272cdbb27402d2201388839845b6a6c
|
4
|
+
data.tar.gz: db131a7480b6f328d021303c13f6fb6b5f42a5b975739d8b86424a9deab67ed6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
56
|
-
options_for_currency = options.merge(from: [Symbol, String])
|
56
|
+
options = options.slice(:to)
|
57
57
|
|
58
|
-
|
59
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
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, **
|
37
|
+
_deserialize(context, **parsed_data)
|
36
38
|
end
|
37
39
|
rescue Datory::Service::Exceptions::Input,
|
38
40
|
Datory::Service::Exceptions::Internal,
|
data/lib/datory/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2024-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|