active_record-acts_as 5.0.2 → 5.0.3
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 +4 -0
- data/CHANGELOG.md +5 -0
- data/active_record-acts_as.gemspec +1 -0
- data/lib/active_record/acts_as.rb +1 -0
- data/lib/active_record/acts_as/class_methods.rb +1 -1
- data/lib/active_record/acts_as/instance_methods.rb +1 -1
- data/lib/active_record/acts_as/version.rb +1 -1
- data/spec/acts_as_spec.rb +8 -0
- data/spec/models.rb +8 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecd8cd75c441652a7719cc0b040d77a84a95f30b1ea8b19c02aa35fb6bdcd425
|
4
|
+
data.tar.gz: a94c71a0cc0dec6e7468cc3949260ee521320a15ab09d433a7c6323aa8b2114d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea6d3e0caa50e3a5e39543684bf372e4d64d5b8adfeb29686523b6674d7d1f4d42449b924f657814cd2c14894068a019d8a8796c45efcc1a76bc1c8cac0ea886
|
7
|
+
data.tar.gz: 9d12820c023f3c0f9d11594b17c904da1ece86fa4381a791cb84f086cde101078140ab9219dfee08185c7e90143d3ae1cffe7abe4f829e427fce002da72c8366
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -23,7 +23,7 @@ module ActiveRecord
|
|
23
23
|
acting_as_model.methods_callable_by_submodel.include?(method) || super
|
24
24
|
end
|
25
25
|
|
26
|
-
def method_missing(method, *args, &block)
|
26
|
+
ruby2_keywords def method_missing(method, *args, &block)
|
27
27
|
if acting_as_model.methods_callable_by_submodel.include?(method)
|
28
28
|
result = acting_as_model.public_send(method, *args, &block)
|
29
29
|
if result.is_a?(ActiveRecord::Relation)
|
@@ -117,7 +117,7 @@ module ActiveRecord
|
|
117
117
|
duplicate
|
118
118
|
end
|
119
119
|
|
120
|
-
def method_missing(method, *args, &block)
|
120
|
+
ruby2_keywords def method_missing(method, *args, &block)
|
121
121
|
if !self_respond_to?(method) && acting_as.respond_to?(method)
|
122
122
|
acting_as.send(method, *args, &block)
|
123
123
|
else
|
data/spec/acts_as_spec.rb
CHANGED
@@ -157,6 +157,10 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
|
|
157
157
|
expect(pen.present).to eq("pen - $0.8")
|
158
158
|
end
|
159
159
|
|
160
|
+
it "responds to supermodel methods with keyword arguments" do
|
161
|
+
expect(pen.keyword_method(one: 3, two: 4)).to eq [3,4]
|
162
|
+
end
|
163
|
+
|
160
164
|
it 'responds to serialized attribute' do
|
161
165
|
expect(pen).to respond_to('option1')
|
162
166
|
expect(isolated_pen).to respond_to('option2')
|
@@ -452,6 +456,10 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
|
|
452
456
|
expect(Product.class_method_callable_by_submodel).to eq('class_method_callable_by_submodel')
|
453
457
|
expect(Pen.class_method_callable_by_submodel).to eq('class_method_callable_by_submodel')
|
454
458
|
end
|
459
|
+
|
460
|
+
it 'with keyword arguments can be called from the submodel' do
|
461
|
+
expect(Pen.class_keyword_method_callable_by_submodel(one: 3, two: 4)).to eq([3,4])
|
462
|
+
end
|
455
463
|
end
|
456
464
|
|
457
465
|
context 'when they are neither defined via `scope` nor made callable by submodel' do
|
data/spec/models.rb
CHANGED
@@ -16,6 +16,10 @@ class Product < ActiveRecord::Base
|
|
16
16
|
'class_method'
|
17
17
|
end
|
18
18
|
|
19
|
+
callable_by_submodel def self.class_keyword_method_callable_by_submodel(one: 1, two: 2)
|
20
|
+
[one, two]
|
21
|
+
end
|
22
|
+
|
19
23
|
callable_by_submodel def self.class_method_callable_by_submodel
|
20
24
|
'class_method_callable_by_submodel'
|
21
25
|
end
|
@@ -27,6 +31,10 @@ class Product < ActiveRecord::Base
|
|
27
31
|
def raise_error
|
28
32
|
specific.non_existant_method
|
29
33
|
end
|
34
|
+
|
35
|
+
def keyword_method(one: 1, two: 2)
|
36
|
+
[one, two]
|
37
|
+
end
|
30
38
|
end
|
31
39
|
|
32
40
|
class Payment < ActiveRecord::Base
|
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: 5.0.
|
4
|
+
version: 5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hassan Zamani
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-07-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sqlite3
|
@@ -124,6 +124,20 @@ dependencies:
|
|
124
124
|
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '6.0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: ruby2_keywords
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
127
141
|
description: Simulate multi-table inheritance for activerecord models using a polymorphic
|
128
142
|
association
|
129
143
|
email:
|