undestroyable 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +77 -12
- data/lib/undestroyable/version.rb +1 -1
- metadata +10 -21
data/README.md
CHANGED
@@ -1,23 +1,88 @@
|
|
1
|
-
#
|
1
|
+
# General [![Build Status](https://secure.travis-ci.org/kot-begemot/undestroyable.png?branch=master)](http://travis-ci.org/kot-begemot/undestroyable)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
An aim for this gem is to provide an agile and comfortable way for Ruby developers to get rid of unnecessary data within their project databases.
|
4
|
+
Weather I succeed with it or not is up to you. I will appreciate any advice or help.
|
5
|
+
|
6
|
+
# System Configuration
|
7
|
+
|
8
|
+
In order to setup system configuration add somewhere in project following code
|
9
|
+
|
10
|
+
require 'undestroyable'
|
11
|
+
|
12
|
+
Undestroyable.config.setup do
|
13
|
+
orm :active_record
|
14
|
+
end
|
15
|
+
|
16
|
+
After that you may activate undestroyable for specific model
|
17
|
+
|
18
|
+
class Country < ActiveRecord::Base
|
19
|
+
undestroyable
|
20
|
+
end
|
21
|
+
|
22
|
+
Default strategy is: :column. You may overwrite system strategy by providing a block to `undestroyable`
|
23
|
+
|
24
|
+
class Country < ActiveRecord::Base
|
25
|
+
undestroyable do
|
26
|
+
strategy :dump
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
That will save objects dump into 'dump' table.
|
31
|
+
There is also a possibility for setting default system starategy:
|
32
|
+
|
33
|
+
Undestroyable.config.setup do
|
34
|
+
orm :active_record
|
35
|
+
strategy :table
|
36
|
+
table_suffix :old
|
37
|
+
end
|
38
|
+
|
39
|
+
class Country < ActiveRecord::Base
|
40
|
+
undestroyable
|
41
|
+
end
|
42
|
+
|
43
|
+
That will move deleted record from 'countries' table into 'countries_deleted'. In case 'countries_deleted' contains 'deleted_at' filed it will be updated.
|
44
|
+
If, due to some reason, a different table name is required it can also be provided:
|
45
|
+
|
46
|
+
Undestroyable.config.setup do
|
47
|
+
orm :active_record
|
48
|
+
strategy :table
|
49
|
+
table_suffix :old
|
50
|
+
end
|
51
|
+
|
52
|
+
class Country < ActiveRecord::Base
|
53
|
+
undestroyable do
|
54
|
+
table_name :scrap
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
In that case, the record will be moved from 'countries' table into 'scrap_deleted'.
|
12
59
|
|
13
60
|
# Options:
|
14
61
|
|
62
|
+
* orm (*ONLY FOR SYSTEM CONFIG*)
|
63
|
+
Specifies which orm is used by project
|
64
|
+
* strategy
|
65
|
+
Specifies which strategy should be used
|
15
66
|
* table_name
|
16
67
|
Same as model table.
|
17
68
|
* table_suffix
|
18
69
|
Default prefix is: deleted
|
19
70
|
* full_table_name
|
20
71
|
table_prefix + table_name + table_suffix.
|
72
|
+
* connection
|
73
|
+
Keeps connection information. _NB!_ Compulsary for :database startegy.
|
74
|
+
|
75
|
+
# Strategies
|
76
|
+
|
77
|
+
* none
|
78
|
+
Deletes record, as with usual destroy method.
|
79
|
+
* column
|
80
|
+
Updates deleted_at column of the record. This is default strategy,
|
81
|
+
if undestroyable is activated for model.
|
82
|
+
* table
|
83
|
+
Move record into separate table
|
84
|
+
* database
|
85
|
+
Move record into separate table in remote database
|
21
86
|
|
22
87
|
# Simple usage example:
|
23
88
|
|
@@ -27,11 +92,11 @@
|
|
27
92
|
|
28
93
|
# Complicated usage example:
|
29
94
|
|
30
|
-
class ConceptCat <
|
95
|
+
class ConceptCat < Vehicle
|
31
96
|
undstroyable do
|
32
97
|
startegy :database
|
33
98
|
connection { adapter: "sqlite3", dbfile: ":memory:"}
|
34
99
|
table_name :scrap
|
35
100
|
table_suffix :metalic
|
36
101
|
end
|
37
|
-
end
|
102
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: undestroyable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-03 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &80073320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *80073320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
27
|
-
requirement: &
|
27
|
+
requirement: &80073080 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *80073080
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3
|
38
|
-
requirement: &
|
38
|
+
requirement: &80072870 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *80072870
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: database_cleaner
|
49
|
-
requirement: &
|
49
|
+
requirement: &80072600 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,18 +54,7 @@ dependencies:
|
|
54
54
|
version: 0.7.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: ruby-debug19
|
60
|
-
requirement: &78019660 !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
63
|
-
- - ! '>='
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '0'
|
66
|
-
type: :development
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *78019660
|
57
|
+
version_requirements: *80072600
|
69
58
|
description: An aim or this gem is to provide an agile and comfortable way for Ruby
|
70
59
|
developers to get rid of unnecessary data within their project databases.
|
71
60
|
email:
|