diva 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diva/field_generator.rb +4 -0
- data/lib/diva/model.rb +2 -2
- data/lib/diva/type.rb +5 -1
- data/lib/diva/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: e1f4b5814e98320545b1b911edff9206dd0d701065496f6bc61a89c3ad1e102b
|
4
|
+
data.tar.gz: d07c6bcca5ad1c5c12d45373f3c813232356833fe000c39122b51686af2877d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0bfefc01f13322c81d39ef8cd7c4d31f1e66e30f12b5bb9061b25069eccd524989e0f83b9a84ea82f4d9f63f93a68376100ebbb77f2d1e095aaf06e3c02b53f
|
7
|
+
data.tar.gz: a1c7995794e5aec9cced403b1f59cd57b2e615ecb4dff64acf395b040792af26837f450ab08891aac6c9a0d271cd9fef200a4fed935c6d1ce63e64c2e57b9a14
|
data/lib/diva/field_generator.rb
CHANGED
@@ -9,6 +9,10 @@ class Diva::FieldGenerator
|
|
9
9
|
@model_klass.add_field(field_name, type: :int, required: required)
|
10
10
|
end
|
11
11
|
|
12
|
+
def float(field_name, required: false)
|
13
|
+
@model_klass.add_field(field_name, type: :float, required: required)
|
14
|
+
end
|
15
|
+
|
12
16
|
def string(field_name, required: false)
|
13
17
|
@model_klass.add_field(field_name, type: :string, required: required)
|
14
18
|
end
|
data/lib/diva/model.rb
CHANGED
@@ -106,8 +106,8 @@ class Diva::Model
|
|
106
106
|
raise "argument is #{@value}, not Hash" unless @value.is_a?(Hash)
|
107
107
|
self.class.fields.each do |field|
|
108
108
|
@value[field.name] = field.type.cast(@value[field.name])
|
109
|
-
rescue Diva::InvalidTypeError
|
110
|
-
raise Diva::InvalidTypeError, "#{
|
109
|
+
rescue Diva::InvalidTypeError
|
110
|
+
raise Diva::InvalidTypeError, "#{self.class}.#{field} (#{field.type}): Invalid assign #{@value[field.name].inspect}:#{@value[field.name].class}"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
data/lib/diva/type.rb
CHANGED
@@ -153,7 +153,11 @@ module Diva::Type
|
|
153
153
|
when Integer, Float
|
154
154
|
Time.at(v)
|
155
155
|
when String
|
156
|
-
|
156
|
+
begin
|
157
|
+
Time.iso8601(v)
|
158
|
+
rescue StandardError
|
159
|
+
Time.parse(v)
|
160
|
+
end
|
157
161
|
else
|
158
162
|
raise Diva::InvalidTypeError, "The value is not a `#{name}'."
|
159
163
|
end
|
data/lib/diva/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diva
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshiaki Asai
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|