paranoia 1.0.0 → 1.0.1
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.
- data/Rakefile +6 -0
- data/lib/paranoia.rb +11 -0
- data/lib/paranoia/version.rb +1 -1
- data/test/paranoia_test.rb +40 -0
- metadata +4 -3
data/Rakefile
CHANGED
data/lib/paranoia.rb
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
module Paranoia
|
2
|
+
def self.included(klazz)
|
3
|
+
klazz.extend Query
|
4
|
+
end
|
5
|
+
|
6
|
+
module Query
|
7
|
+
def paranoid? ; true ; end
|
8
|
+
end
|
9
|
+
|
2
10
|
def destroy
|
3
11
|
_run_destroy_callbacks
|
4
12
|
self[:deleted_at] ||= Time.now
|
@@ -17,4 +25,7 @@ class ActiveRecord::Base
|
|
17
25
|
self.send(:include, Paranoia)
|
18
26
|
default_scope :conditions => { :deleted_at => nil }
|
19
27
|
end
|
28
|
+
|
29
|
+
def self.paranoid? ; false ; end
|
30
|
+
def paranoid? ; self.class.paranoid? ; end
|
20
31
|
end
|
data/lib/paranoia/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'active_record'
|
3
|
+
require 'lib/paranoia'
|
4
|
+
|
5
|
+
DB_FILE = 'tmp/test_db'
|
6
|
+
|
7
|
+
FileUtils.mkdir_p File.dirname(DB_FILE)
|
8
|
+
FileUtils.rm_f DB_FILE
|
9
|
+
|
10
|
+
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => DB_FILE
|
11
|
+
ActiveRecord::Base.connection.execute 'CREATE TABLE paranoid_models (id INTEGER NOT NULL PRIMARY KEY)'
|
12
|
+
ActiveRecord::Base.connection.execute 'CREATE TABLE plain_models (id INTEGER NOT NULL PRIMARY KEY)'
|
13
|
+
|
14
|
+
class ParanoiaTest < Test::Unit::TestCase
|
15
|
+
def test_plain_model_class_is_not_paranoid
|
16
|
+
assert_equal false, PlainModel.paranoid?
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_paranoid_model_class_is_paranoid
|
20
|
+
assert_equal true, ParanoidModel.paranoid?
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_plain_models_are_not_paranoid
|
24
|
+
assert_equal false, PlainModel.new.paranoid?
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_paranoid_models_are_paranoid
|
28
|
+
assert_equal true, ParanoidModel.new.paranoid?
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
# Helper classes
|
34
|
+
|
35
|
+
class ParanoidModel < ActiveRecord::Base
|
36
|
+
acts_as_paranoid
|
37
|
+
end
|
38
|
+
|
39
|
+
class PlainModel < ActiveRecord::Base
|
40
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: paranoia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.1
|
6
6
|
platform: ruby
|
7
7
|
authors: []
|
8
8
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-12 00:00:00 +10:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/paranoia.rb
|
53
53
|
- lib/paranoia/version.rb
|
54
54
|
- paranoia.gemspec
|
55
|
+
- test/paranoia_test.rb
|
55
56
|
has_rdoc: true
|
56
57
|
homepage: http://rubygems.org/gems/paranoia
|
57
58
|
licenses: []
|
@@ -76,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
77
|
requirements: []
|
77
78
|
|
78
79
|
rubyforge_project: paranoia
|
79
|
-
rubygems_version: 1.
|
80
|
+
rubygems_version: 1.6.2
|
80
81
|
signing_key:
|
81
82
|
specification_version: 3
|
82
83
|
summary: acts_as_paranoid, without the clusterfuck
|