active_record-acts_as 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +1 -1
- data/lib/active_record/acts_as/instance_methods.rb +1 -0
- data/lib/active_record/acts_as/relation.rb +2 -1
- data/lib/active_record/acts_as/version.rb +1 -1
- data/spec/acts_as_spec.rb +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62e3d1c5bebab4cf760006974c27a8393197e62e
|
4
|
+
data.tar.gz: c003401bb8d69ac018c8703d6fe6dc1a80a11692
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 531a5d66cf6fd9b9063171fd1eeeac403291fa993205c930986c7702a65220a25eb3c8fdb3bf8f059446e74aaff102e2397376f23feeb490fba5bbaeb170d14b
|
7
|
+
data.tar.gz: f31b4cb3855400b7b5809ac46a33897fc8895f4f8aefd8a4c51ea57fe09b3a07988ab66ec9d3eb70f819519fa56f42b438040e952b98f6de60ee9881733fc43a
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## [2.0.0] - 2016-09-14
|
8
|
+
### Added
|
9
|
+
- Added support for Rails 5 (https://github.com/hzamani/active_record-acts_as/pull/80, thanks to [nicklandgrebe](https://github.com/nicklandgrebe)!)
|
10
|
+
- Allow specifying `association_method` parameter (https://github.com/hzamani/active_record-acts_as/pull/72, thanks to [tombowo](https://github.com/tombowo)!)
|
11
|
+
|
12
|
+
### Removed
|
13
|
+
- Dropped support for Ruby < 2.2 and ActiveSupport/ActiveRecord < 4.2
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
- Fixed `remove_actable` migration helper (https://github.com/hzamani/active_record-acts_as/pull/71, thanks to [nuclearpidgeon](https://github.com/nuclearpidgeon)!)
|
17
|
+
|
18
|
+
[Unreleased]: https://github.com/hzamani/active_record-acts_as/compare/v2.0.0...HEAD
|
19
|
+
[2.0.0]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.8...v2.0.0
|
20
|
+
[1.0.8]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.7...v1.0.8
|
21
|
+
[1.0.7]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.6...v1.0.7
|
22
|
+
[1.0.6]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.5...v1.0.6
|
23
|
+
[1.0.5]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.4...v1.0.5
|
24
|
+
[1.0.4]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.3...v1.0.4
|
25
|
+
[1.0.3]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.2...v1.0.3
|
26
|
+
[1.0.2]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.1...v1.0.2
|
27
|
+
[1.0.1]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.0...v1.0.1
|
28
|
+
[1.0.0]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.0.rc...v1.0.0
|
29
|
+
[1.0.0.rc]: https://github.com/hzamani/active_record-acts_as/compare/v1.0.0.pre...v1.0.0.rc
|
data/README.md
CHANGED
@@ -91,7 +91,7 @@ end
|
|
91
91
|
**Make sure** that column names do not match on parent and subclass tables,
|
92
92
|
that will make SQL statements ambiguous and invalid!
|
93
93
|
Specially **DO NOT** use timestamps on subclasses, if you need them define them
|
94
|
-
on parent table and they will be touched after submodel updates.
|
94
|
+
on parent table and they will be touched after submodel updates (You can use the option `touch: false` to skip this behaviour).
|
95
95
|
|
96
96
|
Now `Pen` and `Book` **acts as** `Product`, i.e. they inherit `Product`s **attributes**,
|
97
97
|
**methods** and **validations**. Now you can do things like these:
|
@@ -8,6 +8,7 @@ module ActiveRecord
|
|
8
8
|
def acts_as(name, scope = nil, options = {})
|
9
9
|
options, scope = scope, nil if Hash === scope
|
10
10
|
association_method = options.delete(:association_method)
|
11
|
+
touch = options.delete(:touch)
|
11
12
|
options = {as: :actable, dependent: :destroy, validate: false, autosave: true}.merge options
|
12
13
|
|
13
14
|
cattr_reader(:validates_actable) { options.delete(:validates_actable) == false ? false : true }
|
@@ -24,7 +25,7 @@ module ActiveRecord
|
|
24
25
|
end
|
25
26
|
}
|
26
27
|
validate :actable_must_be_valid
|
27
|
-
after_update :touch_actable
|
28
|
+
after_update :touch_actable unless touch == false
|
28
29
|
|
29
30
|
cattr_reader(:acting_as_reflection) { reflections.stringify_keys[name.to_s] }
|
30
31
|
cattr_reader(:acting_as_name) { name.to_s }
|
data/spec/acts_as_spec.rb
CHANGED
@@ -223,6 +223,12 @@ RSpec.describe "ActiveRecord::Base model with #acts_as called" do
|
|
223
223
|
expect(pen.updated_at).not_to eq(update)
|
224
224
|
end
|
225
225
|
|
226
|
+
it "touches supermodel only when attributes changed" do
|
227
|
+
pen.save
|
228
|
+
|
229
|
+
expect { pen.save }.to_not change { pen.reload.product.updated_at }
|
230
|
+
end
|
231
|
+
|
226
232
|
it "raises NoMethodEror on unexisting method call" do
|
227
233
|
expect { pen.unexisted_method }.to raise_error(NoMethodError)
|
228
234
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-acts_as
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hassan Zamani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- ".rspec"
|
121
121
|
- ".travis.yml"
|
122
122
|
- Appraisals
|
123
|
+
- CHANGELOG.md
|
123
124
|
- Gemfile
|
124
125
|
- LICENSE.txt
|
125
126
|
- README.md
|