active_record-acts_as 2.4.2 → 2.5.0
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/.travis.yml +3 -0
- data/Appraisals +4 -0
- data/README.md +13 -0
- data/active_record-acts_as.gemspec +2 -2
- data/gemfiles/rails_4.2.gemfile +2 -2
- data/gemfiles/rails_5.0.gemfile +2 -2
- data/gemfiles/rails_5.1.gemfile +8 -0
- data/lib/active_record/acts_as/instance_methods.rb +1 -1
- data/lib/active_record/acts_as/relation.rb +2 -2
- data/lib/active_record/acts_as/version.rb +1 -1
- data/spec/migrations_spec.rb +7 -6
- data/spec/spec_helper.rb +5 -0
- metadata +16 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 381abee602366b8d970bc208a1819ff1fdcabeca
|
4
|
+
data.tar.gz: 2d91f0310bc581b9f73082de2f4984c31a0f0345
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 613c0f9a5f14344ca1d69f82ad007b18d12d0089a513eebee7119aeef2e317b05d07e569dd5c31de8e8b1cf5786f69e5ec4e085364355ae9d8438b8dfc6d5755
|
7
|
+
data.tar.gz: 6f4b3bdbda336c4109150a87bb640f2e5e5e7dbe79963a0713c18a08a1cca8aaf564576c05e474ca9d6478d893d71bbcbaf52c6f1cda3c8c00558ad25eb53117
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
data/README.md
CHANGED
@@ -171,6 +171,19 @@ acts_as :person, -> { includes(:friends) }
|
|
171
171
|
|
172
172
|
Make sure you know what you are doing when overwriting `polymorphic` option.
|
173
173
|
|
174
|
+
### Namespaced models
|
175
|
+
|
176
|
+
If your `actable` and `acts_as` models are namespaced, you need to configure them like this:
|
177
|
+
|
178
|
+
```
|
179
|
+
class MyApp::Product < ApplicationRecord
|
180
|
+
actable inverse_of: :pen
|
181
|
+
end
|
182
|
+
|
183
|
+
class MyApp::Pen < ApplicationRecord
|
184
|
+
acts_as :product, class_name: 'MyApp::Product'
|
185
|
+
end
|
186
|
+
```
|
174
187
|
|
175
188
|
## Caveats
|
176
189
|
|
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "appraisal", "~> 2.1"
|
28
28
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
29
29
|
|
30
|
-
spec.add_dependency "activesupport", ">= 4.2"
|
31
|
-
spec.add_dependency "activerecord", ">= 4.2"
|
30
|
+
spec.add_dependency "activesupport", ">= 4.2", "<= 5.0"
|
31
|
+
spec.add_dependency "activerecord", ">= 4.2", "<= 5.0"
|
32
32
|
end
|
data/gemfiles/rails_4.2.gemfile
CHANGED
data/gemfiles/rails_5.0.gemfile
CHANGED
@@ -28,11 +28,11 @@ module ActiveRecord
|
|
28
28
|
validate :actable_must_be_valid if validates_actable
|
29
29
|
|
30
30
|
unless touch == false
|
31
|
-
after_update :touch, if: :changed?
|
31
|
+
after_update :touch, if: ActiveRecord.version.to_s.to_f >= 5.1 ? :saved_changes? : :changed?
|
32
32
|
end
|
33
33
|
|
34
34
|
before_save do
|
35
|
-
@_acting_as_changed = acting_as.changed?
|
35
|
+
@_acting_as_changed = ActiveRecord.version.to_s.to_f >= 5.1 ? acting_as.saved_changes? : acting_as.changed?
|
36
36
|
true
|
37
37
|
end
|
38
38
|
after_commit do
|
data/spec/migrations_spec.rb
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
require 'database_helper'
|
2
2
|
require 'active_record/acts_as'
|
3
3
|
|
4
|
-
|
5
4
|
class Product < ActiveRecord::Base
|
6
5
|
end
|
7
6
|
|
8
|
-
|
7
|
+
migration_class = ActiveRecord::Migration.respond_to?(:[]) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration
|
8
|
+
|
9
|
+
class RemoveActableFromProducts < migration_class
|
9
10
|
def change
|
10
|
-
change_table
|
11
|
+
change_table :products do |t|
|
11
12
|
t.remove_actable
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
class RemoveProduceableFromProducts <
|
17
|
+
class RemoveProduceableFromProducts < migration_class
|
17
18
|
def change
|
18
|
-
change_table
|
19
|
-
t.remove_actable
|
19
|
+
change_table :products do |t|
|
20
|
+
t.remove_actable as: :produceable
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,3 +6,8 @@ RSpec.configure do |config|
|
|
6
6
|
config.filter_run_including focus: true
|
7
7
|
config.run_all_when_everything_filtered = true
|
8
8
|
end
|
9
|
+
|
10
|
+
require 'active_record'
|
11
|
+
if ActiveRecord::Base.respond_to?(:raise_in_transactional_callbacks=)
|
12
|
+
ActiveRecord::Base.raise_in_transactional_callbacks = true
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-acts_as
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hassan Zamani
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sqlite3
|
@@ -102,6 +102,9 @@ dependencies:
|
|
102
102
|
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '4.2'
|
105
|
+
- - "<="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '5.0'
|
105
108
|
type: :runtime
|
106
109
|
prerelease: false
|
107
110
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -109,6 +112,9 @@ dependencies:
|
|
109
112
|
- - ">="
|
110
113
|
- !ruby/object:Gem::Version
|
111
114
|
version: '4.2'
|
115
|
+
- - "<="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '5.0'
|
112
118
|
- !ruby/object:Gem::Dependency
|
113
119
|
name: activerecord
|
114
120
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +122,9 @@ dependencies:
|
|
116
122
|
- - ">="
|
117
123
|
- !ruby/object:Gem::Version
|
118
124
|
version: '4.2'
|
125
|
+
- - "<="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '5.0'
|
119
128
|
type: :runtime
|
120
129
|
prerelease: false
|
121
130
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -123,6 +132,9 @@ dependencies:
|
|
123
132
|
- - ">="
|
124
133
|
- !ruby/object:Gem::Version
|
125
134
|
version: '4.2'
|
135
|
+
- - "<="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '5.0'
|
126
138
|
description: Simulate multi-table inheritance for activerecord models using a plymorphic
|
127
139
|
association
|
128
140
|
email:
|
@@ -148,6 +160,7 @@ files:
|
|
148
160
|
- bin/console
|
149
161
|
- gemfiles/rails_4.2.gemfile
|
150
162
|
- gemfiles/rails_5.0.gemfile
|
163
|
+
- gemfiles/rails_5.1.gemfile
|
151
164
|
- lib/active_record/acts_as.rb
|
152
165
|
- lib/active_record/acts_as/class_methods.rb
|
153
166
|
- lib/active_record/acts_as/instance_methods.rb
|
@@ -184,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
197
|
version: '0'
|
185
198
|
requirements: []
|
186
199
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.6.
|
200
|
+
rubygems_version: 2.6.12
|
188
201
|
signing_key:
|
189
202
|
specification_version: 4
|
190
203
|
summary: Simulate multi-table inheritance for activerecord models
|