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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52c5dec5bafdde2ee52163337ccb79c65cf1ffa0090da2401585dbf567e92abc
4
- data.tar.gz: b022d6956eb21bcca85203eb989b7d1c8b4dd4b3854f17348b2c150af3b2a3c6
3
+ metadata.gz: e1f4b5814e98320545b1b911edff9206dd0d701065496f6bc61a89c3ad1e102b
4
+ data.tar.gz: d07c6bcca5ad1c5c12d45373f3c813232356833fe000c39122b51686af2877d7
5
5
  SHA512:
6
- metadata.gz: 6d7b1858e1b3722d22fe28f45c612dbdaa2a9c30f19658c6d876acf41d6b6e93cd252f6ca69563ef5826148e83881ff8bad34057d71eb4dee1f6b6123543dd2d
7
- data.tar.gz: f11d4bd094c84857fb5f5dc78644cc9940489e47d506b09930dec55d222b7cc2f58f608265d7acaedfb98bcf78e90a959b1d6ea3356eb255d78c297d5a6a70f4
6
+ metadata.gz: a0bfefc01f13322c81d39ef8cd7c4d31f1e66e30f12b5bb9061b25069eccd524989e0f83b9a84ea82f4d9f63f93a68376100ebbb77f2d1e095aaf06e3c02b53f
7
+ data.tar.gz: a1c7995794e5aec9cced403b1f59cd57b2e615ecb4dff64acf395b040792af26837f450ab08891aac6c9a0d271cd9fef200a4fed935c6d1ce63e64c2e57b9a14
@@ -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 => exception
110
- raise Diva::InvalidTypeError, "#{exception} in field `#{field}'"
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
- Time.iso8601(v)
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
@@ -1,3 +1,3 @@
1
1
  module Diva
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.0.1'.freeze
3
3
  end
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.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-04 00:00:00.000000000 Z
11
+ date: 2021-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler