datory 1.0.0.rc5 → 1.0.0.rc6
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 +5 -0
- data/lib/datory/attributes/serialization/serializator.rb +2 -0
- data/lib/datory/utils.rb +5 -4
- data/lib/datory/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36c9c3d73db41d95c3d5bafd98df4bb5002ea1f36cacc7fafa808ccb9f8af8d7
|
4
|
+
data.tar.gz: 56304b66db42d82a4b143711f1192df86f3139979711a0a9c4d6bf6be7f95d85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a741dd5da9f0ad4782c101ce76c1063668fe5c77074ff650edb23e16216dffe3bceb7b049b13301a06a6ac4de37156da84b3ebc3754297bf2509ef9cb09195e
|
7
|
+
data.tar.gz: ec355c7bb2073c0236d4556e6005c874987b3c513389f2efb5c64adb25de3b35f16077579c5468661e53b60a6933217be561d246031d261d8c1e5ab11be0758a
|
@@ -60,6 +60,11 @@ module Datory
|
|
60
60
|
attribute(name, **options)
|
61
61
|
end
|
62
62
|
|
63
|
+
def duration(name, **options)
|
64
|
+
options = options.merge(from: ActiveSupport::Duration)
|
65
|
+
attribute(name, **options)
|
66
|
+
end
|
67
|
+
|
63
68
|
def date(name, **options)
|
64
69
|
options = options.merge(from: Date)
|
65
70
|
attribute(name, **options)
|
data/lib/datory/utils.rb
CHANGED
@@ -5,13 +5,14 @@ module Datory
|
|
5
5
|
module_function
|
6
6
|
|
7
7
|
TRANSFORMATIONS = {
|
8
|
-
Date => ->(value) { Date.parse(value) },
|
9
|
-
Time => ->(value) { Time.parse(value) },
|
10
|
-
DateTime => ->(value) { DateTime.parse(value) },
|
11
8
|
Symbol => ->(value) { value.to_sym },
|
12
9
|
String => ->(value) { value.to_s },
|
13
10
|
Integer => ->(value) { value.to_i },
|
14
|
-
Float => ->(value) { value.to_f }
|
11
|
+
Float => ->(value) { value.to_f },
|
12
|
+
Date => ->(value) { Date.parse(value) },
|
13
|
+
Time => ->(value) { Time.parse(value) },
|
14
|
+
DateTime => ->(value) { DateTime.parse(value) },
|
15
|
+
ActiveSupport::Duration => ->(value) { ActiveSupport::Duration.parse(value) }
|
15
16
|
}.freeze
|
16
17
|
|
17
18
|
private_constant :TRANSFORMATIONS
|
data/lib/datory/version.rb
CHANGED