active_type 0.7.3 → 0.7.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 867f9ba2138e71a56858e804c2cb186b3bbd72ae
4
- data.tar.gz: cf77e9c2d841ecc02fb034f091ec90931eb6f851
3
+ metadata.gz: 3ceac0ff5d69e424f25db88876a0ccada3cb2e0d
4
+ data.tar.gz: 119b57d99755e42b6825bac20b51c99f4f82af24
5
5
  SHA512:
6
- metadata.gz: 407e66f1ddc55f9d3d26e43b042892f8d1b6a5ca9b24745da3635debe0c3c518dc0cc6655da758aa77f2ee048dfdcb45cd5a29d073064cc5884bdd3cae62bc8e
7
- data.tar.gz: 54ab92aa3841753f910fb978cd3824f1799d57d5b1a8b68c6a083a4971d5e729599567b938dc940c43dc25294a75e62b462d75796a53f99ceaccf9739b09a9bd
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.0 rake`.
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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- active_type (0.7.2)
4
+ active_type (0.7.4)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ActiveType
2
- VERSION = '0.7.3'
2
+ VERSION = '0.7.4'
3
3
  end
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.3
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-08-16 00:00:00.000000000 Z
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.4.5.1
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