active_type 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/gemfiles/Gemfile.3.2.mysql2.lock +1 -1
- data/gemfiles/Gemfile.3.2.sqlite3.lock +1 -1
- data/gemfiles/Gemfile.4.0.sqlite3.lock +1 -1
- data/gemfiles/Gemfile.4.1.sqlite3.lock +1 -1
- data/gemfiles/Gemfile.4.2.1.mysql2.lock +1 -1
- data/gemfiles/Gemfile.4.2.1.pg.lock +1 -1
- data/gemfiles/Gemfile.4.2.1.sqlite3.lock +1 -1
- data/gemfiles/Gemfile.5.0.0.sqlite3.lock +1 -1
- data/gemfiles/Gemfile.5.1.0.mysql2.lock +1 -1
- data/gemfiles/Gemfile.5.1.0.pg.lock +1 -1
- data/gemfiles/Gemfile.5.1.0.sqlite3.lock +1 -1
- data/lib/active_type/type_caster.rb +32 -10
- data/lib/active_type/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b5a76b77fa9b0ebd6d4848a56f7029f164aa482
|
4
|
+
data.tar.gz: a9dc6dcfba3488aa7a93a0b4d31f7d94e5d62938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3009761aea806e2c41e231bf01e3fdf875398e7defaa267d90294c2cf9c05ebc71690cc0500437ec889192fc644e720d234c349835e327c0e1417c4d2320ca1
|
7
|
+
data.tar.gz: 9cb6903641b55d50b83d80d6ca1b2335347cebf8956a00bb1e775eaf6cd445228321ca6f504de94c8e67210bfc93943e05715d3575e2814e523dca8e390f14f8
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
ActiveType is in a pre-1.0 state. This means that its APIs and behavior are subject to breaking changes without deprecation notices. Until 1.0, version numbers will follow a [Semver][]-ish `0.y.z` format, where `y` is incremented when new features or breaking changes are introduced, and `z` is incremented for lesser changes or bug fixes.
|
6
6
|
|
7
|
+
|
8
|
+
## [0.7.2][] (2017-07-31)
|
9
|
+
|
10
|
+
* Fixed a bug when converting datetimes from certain strings. This occured if the string included an explicit time zone (i.e. `record.date_time = '2017-07-31 12:30+03:00'`), which was not the local time.
|
11
|
+
|
7
12
|
## [0.7.1][] (2017-06-19)
|
8
13
|
|
9
14
|
* ActiveType::Object no longer requires a database connection on Rails 5+ (it never did on Rails 3 or 4).
|
@@ -22,17 +22,9 @@ module ActiveType
|
|
22
22
|
# outside the classes that have that responsibility.
|
23
23
|
case @type
|
24
24
|
when :integer
|
25
|
-
|
26
|
-
nil
|
27
|
-
else
|
28
|
-
native_type_cast_from_user(value)
|
29
|
-
end
|
25
|
+
cast_integer(value)
|
30
26
|
when :timestamp, :datetime
|
31
|
-
|
32
|
-
if time && ActiveRecord::Base.time_zone_aware_attributes
|
33
|
-
time = ActiveSupport::TimeWithZone.new(nil, Time.zone, time)
|
34
|
-
end
|
35
|
-
time
|
27
|
+
cast_time(value)
|
36
28
|
else
|
37
29
|
native_type_cast_from_user(value)
|
38
30
|
end
|
@@ -42,6 +34,36 @@ module ActiveType
|
|
42
34
|
@native_caster.type_cast_from_user(value)
|
43
35
|
end
|
44
36
|
|
37
|
+
private
|
38
|
+
|
39
|
+
def cast_integer(value)
|
40
|
+
if value == ''
|
41
|
+
nil
|
42
|
+
else
|
43
|
+
native_type_cast_from_user(value)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def cast_time(value)
|
48
|
+
time = nil
|
49
|
+
if ActiveRecord::Base.time_zone_aware_attributes
|
50
|
+
if value.is_a?(String)
|
51
|
+
time = Time.zone.parse(value) rescue nil
|
52
|
+
end
|
53
|
+
time ||= native_type_cast_from_user(value)
|
54
|
+
if time
|
55
|
+
if value.is_a?(String) && value !~ /[+\-Z][\d:]*$/
|
56
|
+
# time was given without an explicit zone, so assume it was given in Time.zone
|
57
|
+
ActiveSupport::TimeWithZone.new(nil, Time.zone, time)
|
58
|
+
else
|
59
|
+
time.in_time_zone rescue time
|
60
|
+
end
|
61
|
+
end
|
62
|
+
else
|
63
|
+
native_type_cast_from_user(value)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
45
67
|
module NativeCasters
|
46
68
|
|
47
69
|
# Adapter for Rails 3.0 - 4.1.
|
data/lib/active_type/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Kraze
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|