paranoia 0.0.1 → 1.0.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.
@@ -0,0 +1,59 @@
1
+ # Paranoia
2
+
3
+ Paranoia is a re-implementation of [acts\_as\_paranoid](http://github.com/technoweenie/acts_as_paranoid) for Rails 3, using much, much, much less code.
4
+
5
+ You would use either plugin / gem if you wished that when you called `destroy` on an Active Record object that it didn't actually destroy it, but just "hid" the record. Paranoia does this by setting a `deleted_at` field to the current time when you `destroy` a record, and hides it by scoping all queries on your model to only include records which do not have a `deleted_at` field.
6
+
7
+ ## Installation & Usage
8
+
9
+ ### Initial installation
10
+
11
+ #### Rails 3
12
+
13
+ In your _Gemfile_:
14
+
15
+ gem 'paranoia'
16
+
17
+ Then run:
18
+
19
+ bundle install
20
+
21
+ #### Rails 2:
22
+
23
+ In your _config/environment.rb_:
24
+
25
+ config.gem 'paranoia'
26
+
27
+ Then run:
28
+
29
+ rake gems:install
30
+
31
+ ### Usage
32
+
33
+ #### In your model:
34
+
35
+ class Client < ActiveRecord::Base
36
+ acts_as_paranoid
37
+
38
+ ...
39
+ end
40
+
41
+ Hey presto, it's there!
42
+
43
+ If you want a method to be called on destroy, simply provide a _before\_destroy_ callback:
44
+
45
+ class Client < ActiveRecord::Base
46
+ acts_as_paranoid
47
+
48
+ before_destroy :some_method
49
+
50
+ def some_method
51
+ # do stuff
52
+ end
53
+
54
+ ...
55
+ end
56
+
57
+ ## License
58
+
59
+ This gem is released under the MIT license.
@@ -1,16 +1,15 @@
1
1
  module Paranoia
2
- def deleted?
3
- !!self["deleted_at"]
4
- end
5
-
6
2
  def destroy
7
- self["deleted_at"] = Time.now
8
- self.save
9
3
  _run_destroy_callbacks
4
+ self[:deleted_at] ||= Time.now
5
+ self.save
6
+ end
7
+ alias :delete :destroy
8
+
9
+ def destroyed?
10
+ !self[:deleted_at].nil?
10
11
  end
11
-
12
- alias_method :delete, :destroy
13
-
12
+ alias :deleted? :destroyed?
14
13
  end
15
14
 
16
15
  class ActiveRecord::Base
@@ -19,4 +18,3 @@ class ActiveRecord::Base
19
18
  default_scope :conditions => { :deleted_at => nil }
20
19
  end
21
20
  end
22
-
@@ -1,3 +1,3 @@
1
1
  module Paranoia
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.required_rubygems_version = ">= 1.3.6"
15
15
  s.rubyforge_project = "paranoia"
16
16
 
17
- s.add_dependency "activerecord", "~> 3.0.0"
17
+ s.add_dependency "activerecord", ">= 3.0.0"
18
18
 
19
19
  s.add_development_dependency "bundler", ">= 1.0.0"
20
20
 
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paranoia
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 1
9
- version: 0.0.1
4
+ prerelease:
5
+ version: 1.0.0
10
6
  platform: ruby
11
7
  authors: []
12
8
 
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-10-07 00:00:00 +11:00
13
+ date: 2011-04-06 00:00:00 +10:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -23,12 +19,8 @@ dependencies:
23
19
  requirement: &id001 !ruby/object:Gem::Requirement
24
20
  none: false
25
21
  requirements:
26
- - - ~>
22
+ - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 3
30
- - 0
31
- - 0
32
24
  version: 3.0.0
33
25
  type: :runtime
34
26
  version_requirements: *id001
@@ -40,10 +32,6 @@ dependencies:
40
32
  requirements:
41
33
  - - ">="
42
34
  - !ruby/object:Gem::Version
43
- segments:
44
- - 1
45
- - 0
46
- - 0
47
35
  version: 1.0.0
48
36
  type: :development
49
37
  version_requirements: *id002
@@ -59,6 +47,7 @@ extra_rdoc_files: []
59
47
  files:
60
48
  - .gitignore
61
49
  - Gemfile
50
+ - README.md
62
51
  - Rakefile
63
52
  - lib/paranoia.rb
64
53
  - lib/paranoia/version.rb
@@ -77,23 +66,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
66
  requirements:
78
67
  - - ">="
79
68
  - !ruby/object:Gem::Version
80
- segments:
81
- - 0
82
69
  version: "0"
83
70
  required_rubygems_version: !ruby/object:Gem::Requirement
84
71
  none: false
85
72
  requirements:
86
73
  - - ">="
87
74
  - !ruby/object:Gem::Version
88
- segments:
89
- - 1
90
- - 3
91
- - 6
92
75
  version: 1.3.6
93
76
  requirements: []
94
77
 
95
78
  rubyforge_project: paranoia
96
- rubygems_version: 1.3.7
79
+ rubygems_version: 1.5.2
97
80
  signing_key:
98
81
  specification_version: 3
99
82
  summary: acts_as_paranoid, without the clusterfuck