active_type 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -1
- 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/util.rb +10 -0
- data/lib/active_type/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: 3ceac0ff5d69e424f25db88876a0ccada3cb2e0d
|
4
|
+
data.tar.gz: 119b57d99755e42b6825bac20b51c99f4f82af24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b40e8952fdd1461482c4428b5d67a62472da336be0d7f378cd8e554e5075b49b7cce063263eabf9e31ea92f9c063127484f1d09fe0b49e06b788120ee008f5a
|
7
|
+
data.tar.gz: ba9859e705d88a8cccffe9f3f4656177d0f3df045d81cdfc9e9fdc351dd21195ca2afa76901cb75c90d23466070681a96374f735ca2f8d7efb2e630df7a63372
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,9 @@ 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
|
+
## [0.7.4][] (2017-09-01)
|
8
|
+
|
9
|
+
* Bugfix: ActiveType.cast sets #type correctly when casting to an STI class
|
7
10
|
|
8
11
|
## [0.7.3][] (2017-08-16)
|
9
12
|
|
data/README.md
CHANGED
@@ -378,7 +378,7 @@ Development
|
|
378
378
|
- We run tests against several ActiveRecord versions.
|
379
379
|
- You can bundle all versions with `rake all:install`.
|
380
380
|
- You can run specs against all versions with `rake all:spec`.
|
381
|
-
- You can run specs against a single version with `VERSION=4.
|
381
|
+
- You can run specs against a single version with `VERSION=4.2.1.pg rake` or `VERSION="4.2.1.*" rake`.
|
382
382
|
|
383
383
|
If you are getting testing failures due to Mysql trying to connect as `root` user, you can put your Mysql credentials into `spec/support/database.yml`.
|
384
384
|
See `spec/support/database.sample.yml` for an example.
|
data/lib/active_type/util.rb
CHANGED
@@ -20,6 +20,8 @@ module ActiveType
|
|
20
20
|
def cast_record(record, klass)
|
21
21
|
# record.becomes(klass).dup
|
22
22
|
klass.new do |casted|
|
23
|
+
using_single_table_inheritance = using_single_table_inheritance?(klass, casted)
|
24
|
+
|
23
25
|
# Rails 3.2, 4.2
|
24
26
|
casted.instance_variable_set(:@attributes, record.instance_variable_get(:@attributes))
|
25
27
|
# Rails 3.2
|
@@ -41,9 +43,17 @@ module ActiveType
|
|
41
43
|
errors.instance_variable_set(:@base, casted)
|
42
44
|
end
|
43
45
|
casted.instance_variable_set(:@errors, errors)
|
46
|
+
|
47
|
+
casted[klass.inheritance_column] = klass.sti_name if using_single_table_inheritance
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
51
|
+
# Backport for Rails 3.2
|
52
|
+
def using_single_table_inheritance?(klass, record)
|
53
|
+
inheritance_column = klass.inheritance_column
|
54
|
+
record[inheritance_column].present? && record.has_attribute?(inheritance_column)
|
55
|
+
end
|
56
|
+
|
47
57
|
def cast_relation(relation, klass)
|
48
58
|
scoped(klass).merge(scoped(relation))
|
49
59
|
end
|
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.4
|
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-09-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.6.13
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: Make any Ruby object quack like ActiveRecord
|