diva 0.3.0 → 0.3.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.rb +4 -0
- data/lib/diva/model.rb +3 -1
- data/lib/diva/type.rb +25 -2
- data/lib/diva/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbd71e6eab2ac33b0889772975d9eca73bc410b4
|
4
|
+
data.tar.gz: 9b22e2df9cef290b873554f511266cbd844cbebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f13d1159a00b3476b2ce4718a11d3dda0cd037210bab256d3d6b2e32aa0fcd71afc2b3366446b538ba867b0a907411f91f54f45a722cfe17f723a80fd0c1bd9
|
7
|
+
data.tar.gz: 60a7677cbba7d4716b7246428c36b9b27e15ad9a4fc7299a7eb03de2594fcb8cb6f9f5945f40f7d4a4877121e005c4c3008608ab65307ff4d095fa0f16b7f7b6
|
data/lib/diva/field.rb
CHANGED
data/lib/diva/model.rb
CHANGED
data/lib/diva/type.rb
CHANGED
@@ -27,6 +27,8 @@ Diva::Modelのサブクラスであれば、それを制約とすることがで
|
|
27
27
|
配列の全ての要素が設定された制約を満たしていれば、配列制約が満たされたことになる。
|
28
28
|
|
29
29
|
=end
|
30
|
+
require "time"
|
31
|
+
|
30
32
|
module Diva::Type
|
31
33
|
extend self
|
32
34
|
|
@@ -61,6 +63,10 @@ module Diva::Type
|
|
61
63
|
name.to_s
|
62
64
|
end
|
63
65
|
|
66
|
+
def dump_for_json(value)
|
67
|
+
value
|
68
|
+
end
|
69
|
+
|
64
70
|
def inspect
|
65
71
|
"Diva::Type(#{to_s})"
|
66
72
|
end
|
@@ -113,14 +119,19 @@ module Diva::Type
|
|
113
119
|
v.to_s
|
114
120
|
end
|
115
121
|
end
|
116
|
-
|
122
|
+
class TimeType < AtomicType
|
123
|
+
def dump_for_json(value)
|
124
|
+
cast(value).iso8601
|
125
|
+
end
|
126
|
+
end
|
127
|
+
TIME = TimeType.new(:time) do |v|
|
117
128
|
case v
|
118
129
|
when Time
|
119
130
|
v
|
120
131
|
when Integer, Float
|
121
132
|
Time.at(v)
|
122
133
|
when String
|
123
|
-
Time.
|
134
|
+
Time.iso8601(v)
|
124
135
|
else
|
125
136
|
raise Diva::InvalidTypeError, "The value is not a `#{name}'."
|
126
137
|
end
|
@@ -171,6 +182,10 @@ module Diva::Type
|
|
171
182
|
value.to_a.map(&@type.method(:cast))
|
172
183
|
end
|
173
184
|
|
185
|
+
def dump_for_json(value)
|
186
|
+
value.to_a.map(&@type.method(:dump_for_json))
|
187
|
+
end
|
188
|
+
|
174
189
|
def to_s
|
175
190
|
"Array of #{@type.to_s}"
|
176
191
|
end
|
@@ -190,6 +205,14 @@ module Diva::Type
|
|
190
205
|
end
|
191
206
|
end
|
192
207
|
|
208
|
+
def dump_for_json(value)
|
209
|
+
if value.nil?
|
210
|
+
value
|
211
|
+
else
|
212
|
+
@type.dump_for_json(value)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
193
216
|
def to_s
|
194
217
|
"#{@type.to_s}|nil"
|
195
218
|
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: 0.3.
|
4
|
+
version: 0.3.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:
|
11
|
+
date: 2018-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
150
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.6.
|
151
|
+
rubygems_version: 2.6.14
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: Implementation of expression for handling things.
|