rice_bubble 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -1
- data/lib/rice_bubble/attributes/datetime.rb +28 -0
- data/lib/rice_bubble/version.rb +1 -1
- data/lib/rice_bubble.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ff1a10fe0388c60a178246ee4c45a005292355ec741b9f175b56c8ba393b060
|
4
|
+
data.tar.gz: 35c94ec3a32ea7187b031eaf4341c59ad4a55649510bece671a52b480a10c2c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eb7c799044b2d70f6f13a2066d175b4ff09965b19b11d91c36493509d579e6e9ea6ebbeb4cfe1d897faf5aded93bc74ea5e955db81fc396bda9a292689537c3
|
7
|
+
data.tar.gz: 9bd2f3aa7f5c6c70ebb5c8afc1d2ca2d4ee95e2978c5491c5a6a1e225ce31c4f3ea5e908a933fa48d74e1cea4d437e131f1718c5e0c496df7c7bf0f99196699b
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
module RiceBubble
|
2
|
+
class Attributes
|
3
|
+
class Datetime < Base
|
4
|
+
def valid?(value)
|
5
|
+
return false unless valid_datetime?(value)
|
6
|
+
|
7
|
+
value.respond_to?(:to_datetime)
|
8
|
+
end
|
9
|
+
|
10
|
+
def coerce(value)
|
11
|
+
return nil unless valid_datetime?(value)
|
12
|
+
|
13
|
+
value.respond_to?(:to_datetime) ? value.to_datetime : value
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def valid_datetime?(value)
|
19
|
+
case value
|
20
|
+
when ::Time then true
|
21
|
+
when ::DateTime then true
|
22
|
+
when ::Date then false
|
23
|
+
else value.respond_to?(:to_datetime)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/rice_bubble/version.rb
CHANGED
data/lib/rice_bubble.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative 'rice_bubble/attributes/any'
|
|
5
5
|
require_relative 'rice_bubble/attributes/array'
|
6
6
|
require_relative 'rice_bubble/attributes/boolean'
|
7
7
|
require_relative 'rice_bubble/attributes/date'
|
8
|
+
require_relative 'rice_bubble/attributes/datetime'
|
8
9
|
require_relative 'rice_bubble/attributes/enum'
|
9
10
|
require_relative 'rice_bubble/attributes/number'
|
10
11
|
require_relative 'rice_bubble/attributes/integer'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rice_bubble
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/rice_bubble/attributes/base.rb
|
147
147
|
- lib/rice_bubble/attributes/boolean.rb
|
148
148
|
- lib/rice_bubble/attributes/date.rb
|
149
|
+
- lib/rice_bubble/attributes/datetime.rb
|
149
150
|
- lib/rice_bubble/attributes/enum.rb
|
150
151
|
- lib/rice_bubble/attributes/integer.rb
|
151
152
|
- lib/rice_bubble/attributes/literal.rb
|