active_record-acts_as 2.5.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +1 -2
- data/Appraisals +4 -0
- data/README.md +1 -1
- data/active_record-acts_as.gemspec +2 -2
- data/gemfiles/rails_5.2.gemfile +8 -0
- data/lib/active_record/acts_as/instance_methods.rb +4 -0
- data/lib/active_record/acts_as/querying.rb +5 -5
- data/lib/active_record/acts_as/relation.rb +1 -1
- data/lib/active_record/acts_as/version.rb +1 -1
- data/spec/acts_as_spec.rb +9 -2
- data/spec/models.rb +1 -1
- metadata +4 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9a9bc3e4aeba36e8d79f1ae9da8d8a542d8536a40ef33338bb5b6008b7957816
|
4
|
+
data.tar.gz: 9a774bbf389710f7abe0fd2aa8a4e212d0198cdc73c4a454be1054680814280d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b34df64d7c458ccc596f9d6f3a6ccfb32029c98242406205d87af13b2e2a5dfc0aefb779d2ba81fb36c5f5936c074f64307365ccdc5febddee8f92dee5df4ccf
|
7
|
+
data.tar.gz: bdb531a26f0e161e58a637ff4f0c1d81b255c7d252a0f7835cc505a748ba119cd4fdec1ded399af018e9e5141903a54d854253ee2e03315b9fd2a2d1d37cd6f7
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
data/README.md
CHANGED
@@ -177,7 +177,7 @@ If your `actable` and `acts_as` models are namespaced, you need to configure the
|
|
177
177
|
|
178
178
|
```
|
179
179
|
class MyApp::Product < ApplicationRecord
|
180
|
-
actable inverse_of: :
|
180
|
+
actable inverse_of: :product
|
181
181
|
end
|
182
182
|
|
183
183
|
class MyApp::Pen < ApplicationRecord
|
@@ -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"
|
31
|
+
spec.add_dependency "activerecord", ">= 4.2"
|
32
32
|
end
|
@@ -9,6 +9,10 @@ module ActiveRecord
|
|
9
9
|
super || acting_as?(klass)
|
10
10
|
end
|
11
11
|
|
12
|
+
def saved_changes?
|
13
|
+
super || acting_as.has_changes_to_save? || (defined?(@_acting_as_changed) ? @_acting_as_changed : false)
|
14
|
+
end
|
15
|
+
|
12
16
|
def changed?
|
13
17
|
super || acting_as.changed? || (defined?(@_acting_as_changed) ? @_acting_as_changed : false)
|
14
18
|
end
|
@@ -26,12 +26,12 @@ module ActiveRecord
|
|
26
26
|
end
|
27
27
|
|
28
28
|
module ScopeForCreate
|
29
|
-
def scope_for_create
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
where_values_hash.merge(create_with_value)
|
29
|
+
def scope_for_create(attributes = nil)
|
30
|
+
scope = ActiveRecord.version.to_s.to_f >= 5.2 ? super(attributes) : where_values_hash
|
31
|
+
if acting_as?
|
32
|
+
scope.merge!(where_values_hash(acting_as_model.table_name))
|
34
33
|
end
|
34
|
+
scope.merge(create_with_value)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -32,7 +32,7 @@ module ActiveRecord
|
|
32
32
|
end
|
33
33
|
|
34
34
|
before_save do
|
35
|
-
@_acting_as_changed = ActiveRecord.version.to_s.to_f >= 5.1 ? acting_as.
|
35
|
+
@_acting_as_changed = ActiveRecord.version.to_s.to_f >= 5.1 ? acting_as.has_changes_to_save? : acting_as.changed?
|
36
36
|
true
|
37
37
|
end
|
38
38
|
after_commit do
|
data/spec/acts_as_spec.rb
CHANGED
@@ -496,8 +496,7 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
|
|
496
496
|
describe '.scope_for_create' do
|
497
497
|
it 'includes supermodel attributes' do
|
498
498
|
relation = Pen.where(name: 'new name', price: 1.4, color: 'red')
|
499
|
-
|
500
|
-
expect(relation.scope_for_create.keys).to include('name')
|
499
|
+
expect(relation.scope_for_create).to include('name')
|
501
500
|
expect(relation.scope_for_create['name']).to eq('new name')
|
502
501
|
end
|
503
502
|
end
|
@@ -516,6 +515,14 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
|
|
516
515
|
it "has a cattr_reader for the acting_as_model" do
|
517
516
|
expect(subject.acting_as_model).to eq Inventory::ProductFeature
|
518
517
|
end
|
518
|
+
|
519
|
+
it "can be created" do
|
520
|
+
expect(
|
521
|
+
Inventory::PenLid.create name: 'steve',
|
522
|
+
price: 10.1,
|
523
|
+
color: 'beige'
|
524
|
+
).to be_a_kind_of Inventory::PenLid
|
525
|
+
end
|
519
526
|
end
|
520
527
|
|
521
528
|
context 'different association_methods' do
|
data/spec/models.rb
CHANGED
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:
|
4
|
+
version: 3.0.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:
|
12
|
+
date: 2018-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sqlite3
|
@@ -102,9 +102,6 @@ dependencies:
|
|
102
102
|
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '4.2'
|
105
|
-
- - "<="
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: '5.0'
|
108
105
|
type: :runtime
|
109
106
|
prerelease: false
|
110
107
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -112,9 +109,6 @@ dependencies:
|
|
112
109
|
- - ">="
|
113
110
|
- !ruby/object:Gem::Version
|
114
111
|
version: '4.2'
|
115
|
-
- - "<="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '5.0'
|
118
112
|
- !ruby/object:Gem::Dependency
|
119
113
|
name: activerecord
|
120
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,9 +116,6 @@ dependencies:
|
|
122
116
|
- - ">="
|
123
117
|
- !ruby/object:Gem::Version
|
124
118
|
version: '4.2'
|
125
|
-
- - "<="
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '5.0'
|
128
119
|
type: :runtime
|
129
120
|
prerelease: false
|
130
121
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -132,9 +123,6 @@ dependencies:
|
|
132
123
|
- - ">="
|
133
124
|
- !ruby/object:Gem::Version
|
134
125
|
version: '4.2'
|
135
|
-
- - "<="
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '5.0'
|
138
126
|
description: Simulate multi-table inheritance for activerecord models using a plymorphic
|
139
127
|
association
|
140
128
|
email:
|
@@ -161,6 +149,7 @@ files:
|
|
161
149
|
- gemfiles/rails_4.2.gemfile
|
162
150
|
- gemfiles/rails_5.0.gemfile
|
163
151
|
- gemfiles/rails_5.1.gemfile
|
152
|
+
- gemfiles/rails_5.2.gemfile
|
164
153
|
- lib/active_record/acts_as.rb
|
165
154
|
- lib/active_record/acts_as/class_methods.rb
|
166
155
|
- lib/active_record/acts_as/instance_methods.rb
|
@@ -197,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
186
|
version: '0'
|
198
187
|
requirements: []
|
199
188
|
rubyforge_project:
|
200
|
-
rubygems_version: 2.6
|
189
|
+
rubygems_version: 2.7.6
|
201
190
|
signing_key:
|
202
191
|
specification_version: 4
|
203
192
|
summary: Simulate multi-table inheritance for activerecord models
|