acts_as_archival 0.6.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 175bbdb26230acbbbee4329bda6dd6bfc6eae3d5
4
- data.tar.gz: d07f9da7b94fa39b6768cb369e20f7f84ddd4585
3
+ metadata.gz: cff5862053f75da82a37e18eb5f014118fcc4702
4
+ data.tar.gz: a3289e80a677888517c5862d4905f2cbb44aad0f
5
5
  SHA512:
6
- metadata.gz: 995e99fa5c849235e10b5b7588cf1fa62fcb97271833ca941462d832769fd32ffbefd02f3d0f9dbacdb6bd0bb3c0bfd65b2fd6ea08425d937cd7e42aa82ecc27
7
- data.tar.gz: 00f416f9999d273e490d56aad4309f3b639518a4868c904fb79d7f3a747b0c6b70df4c108646e8b91205ffc14d7f77d594d069c6bb912b4c0ee04cf92bd2f81c
6
+ metadata.gz: 175eb9267a176e8047d4f23b6e5bd4c3c25e496f4ce4bcb61d61ccafd93ae5fddf2f6b9a9ece625a68bd76df83c82cb8e6b110ccec1ad958f37663aeeed11eba
7
+ data.tar.gz: f9abce355fe369749c02bf609ad2abfbfad7e482fb3393c3d12bdf9ef13b99fd80afdaa0ad83bcb9e512ae57f3527510d8279a4f8989f269a0b1a055fbdadf73
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
- # Changes!
1
+ # CHANGELOG
2
+
3
+ ## 1.0.0
4
+ * **BREAKING CHANGE** make `#archived?` return an actual boolean value
2
5
 
3
6
  ## 0.6.1
4
7
  * Fix deprecation warnings on Rails 4.1
data/README.md CHANGED
@@ -15,6 +15,10 @@ Additionally, other plugins generally screw with how
15
15
  `destroy`/`delete` work. We don't because we actually want to be able
16
16
  to destroy records.
17
17
 
18
+ ## Maintenance
19
+
20
+ You might read the commit logs and think "This must be abandonware! This hasn't been updated in 2y!" But! This is a mature project that solves a specific problem in ActiveRecord. It tends to only be updated when a new major version of ActiveRecord comes out and hence the infrequent updates.
21
+
18
22
  ## Install
19
23
 
20
24
  Gemfile:
@@ -27,7 +31,7 @@ i.e. `rails g migration AddAAAToPost archive_number archived_at:datetime`
27
31
 
28
32
  Any dependent-destroy AAA model associated to an AAA model will be archived with its parent.
29
33
 
30
- _If you're stuck on Rails 3.0x/2, check out the available branches._
34
+ _If you're stuck on Rails 3x/2x, check out the available branches, which are no longer in active development._
31
35
 
32
36
  ## Example
33
37
 
@@ -48,7 +52,7 @@ end
48
52
  h = Hole.create #
49
53
  h.archived? # => false
50
54
  h.archive # => true
51
- h.archived? # => "b56876de48a5dcfe71b2c13eec15e4a2"
55
+ h.archived? # => true
52
56
  h.archive_number # => "b56876de48a5dcfe71b2c13eec15e4a2"
53
57
  h.archived_at # => Thu, 01 Jan 2012 01:49:21 -0400
54
58
  h.unarchive # => true
@@ -65,7 +69,7 @@ r = h.rats.create #
65
69
  h.archive # => true
66
70
  h.archive_number # => "b56876de48a5dcfe71b2c13eec15e4a2"
67
71
  r.archive_number # => "b56876de48a5dcfe71b2c13eec15e4a2"
68
- r.archived? # => "b56876de48a5dcfe71b2c13eec15e4a2"
72
+ r.archived? # => true
69
73
  h.unarchive # => true
70
74
  h.archive_number # => nil
71
75
  r.archive_number # => nil
@@ -109,6 +113,30 @@ record.save # => false
109
113
  record.errors.full_messages.first # => "Cannot modify an archived record."
110
114
  ```
111
115
 
116
+ ### Callbacks
117
+
118
+ AAA models have four additional callbacks to do any necessary cleanup or other processing before and after archiving and unarchiving, and can additionally halt the archive callback chain.
119
+
120
+ ``` ruby
121
+ class Hole < ActiveRecord::Base
122
+ acts_as_archival
123
+
124
+ before_archive :some_method_before_archiving
125
+
126
+ after_archive :some_method_after_archiving
127
+
128
+ before_unarchive :some_method_before_unarchiving
129
+
130
+ after_unarchive :some_method_before_unarchiving
131
+
132
+ # ... implement those methods
133
+ end
134
+ ```
135
+
136
+ #### Halting the callback chain
137
+
138
+ The callback method should return a `false` value.
139
+
112
140
  ## Caveats
113
141
 
114
142
  1. This will only work on associations that are dependent destroy. It
@@ -153,4 +181,4 @@ ActsAsParanoid and PermanentRecords were both inspirations for this:
153
181
 
154
182
  Thanks!
155
183
 
156
- *Copyright (c) 2009-2013 Expected Behavior, LLC, released under the MIT license*
184
+ *Copyright (c) 2009-2016 Expected Behavior, LLC, released under the MIT license*
@@ -16,10 +16,8 @@ Gem::Specification.new do |gem|
16
16
  "James Hill",
17
17
  "Maarten Claes"]
18
18
  gem.email = ["joel@expectedbehavior.com",
19
- "michael@expectedbehavior.com",
20
19
  "matt@expectedbehavior.com",
21
20
  "jason@expectedbehavior.com",
22
- "tyler@expectedbehavior.com",
23
21
  "nathan@expectedbehavior.com"]
24
22
  gem.homepage = "http://github.com/expectedbehavior/acts_as_archival"
25
23
 
@@ -1,3 +1,3 @@
1
1
  module ActsAsArchival
2
- VERSION = "0.6.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -55,7 +55,7 @@ module ExpectedBehavior
55
55
  end
56
56
 
57
57
  def archived?
58
- self.archived_at? && self.archive_number
58
+ !!(self.archived_at? && self.archive_number)
59
59
  end
60
60
 
61
61
  def archive(head_archive_number=nil)
data/test/basic_test.rb CHANGED
@@ -4,13 +4,13 @@ class BasicTest < ActiveSupport::TestCase
4
4
  test "archive archives the record" do
5
5
  archival = Archival.create!
6
6
  archival.archive
7
- assert archival.reload.archived?
7
+ assert_equal true, archival.reload.archived?
8
8
  end
9
9
 
10
10
  test "unarchive unarchives archival records" do
11
11
  archival = Archival.create!(:archived_at => Time.now, :archive_number => 1)
12
12
  archival.unarchive
13
- assert_not archival.reload.archived?
13
+ assert_equal false, archival.reload.archived?
14
14
  end
15
15
 
16
16
  test "archive returns true on success" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_archival
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Meador
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2014-07-24 00:00:00.000000000 Z
19
+ date: 2016-04-05 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activerecord
@@ -160,10 +160,8 @@ description: |
160
160
  don't because we actually want to be able to destroy records.
161
161
  email:
162
162
  - joel@expectedbehavior.com
163
- - michael@expectedbehavior.com
164
163
  - matt@expectedbehavior.com
165
164
  - jason@expectedbehavior.com
166
- - tyler@expectedbehavior.com
167
165
  - nathan@expectedbehavior.com
168
166
  executables: []
169
167
  extensions: []
@@ -240,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
238
  version: '0'
241
239
  requirements: []
242
240
  rubyforge_project:
243
- rubygems_version: 2.2.2
241
+ rubygems_version: 2.5.1
244
242
  signing_key:
245
243
  specification_version: 4
246
244
  summary: Atomic archiving/unarchiving for ActiveRecord-based apps