memento 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +9 -0
- data/lib/memento/action.rb +5 -6
- data/lib/memento/active_record_methods.rb +7 -3
- data/lib/memento/version.rb +1 -1
- data/lib/memento.rb +0 -1
- data/spec/memento/active_record_methods_spec.rb +4 -0
- metadata +8 -16
data/CHANGES.md
ADDED
data/lib/memento/action.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support/core_ext/class/attribute'
|
2
|
+
|
1
3
|
module Memento::Action
|
2
4
|
class Base
|
3
5
|
def initialize(state)
|
@@ -5,6 +7,8 @@ module Memento::Action
|
|
5
7
|
end
|
6
8
|
|
7
9
|
attr_reader :state
|
10
|
+
class_attribute :action_types, :instance_reader => false, :instance_writer => false
|
11
|
+
self.action_types = []
|
8
12
|
|
9
13
|
def record
|
10
14
|
@state.record
|
@@ -19,12 +23,7 @@ module Memento::Action
|
|
19
23
|
end
|
20
24
|
|
21
25
|
def self.inherited(child)
|
22
|
-
|
23
|
-
write_inheritable_attribute(:action_types, action_types << action_type)
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.action_types
|
27
|
-
read_inheritable_attribute(:action_types) || []
|
26
|
+
self.action_types << child.name.demodulize.underscore
|
28
27
|
end
|
29
28
|
|
30
29
|
private
|
@@ -1,9 +1,13 @@
|
|
1
|
+
require 'active_support/core_ext/class/attribute'
|
2
|
+
|
1
3
|
module Memento::ActiveRecordMethods
|
2
4
|
|
3
5
|
IGNORE_ATTRIBUTES = [:updated_at, :created_at]
|
4
6
|
|
5
7
|
def self.included(base)
|
6
|
-
base.
|
8
|
+
base.class_attribute(:memento_options_store, :instance_reader => false, :instance_writer => false)
|
9
|
+
base.memento_options_store = {}
|
10
|
+
base.extend ClassMethods
|
7
11
|
end
|
8
12
|
|
9
13
|
module ClassMethods
|
@@ -33,13 +37,13 @@ module Memento::ActiveRecordMethods
|
|
33
37
|
end
|
34
38
|
|
35
39
|
def memento_options
|
36
|
-
|
40
|
+
self.memento_options_store ||= {}
|
37
41
|
end
|
38
42
|
|
39
43
|
def memento_options=(options)
|
40
44
|
options.symbolize_keys!
|
41
45
|
options[:ignore] = [options[:ignore]].flatten.map(&:to_sym) if options[:ignore]
|
42
|
-
|
46
|
+
self.memento_options_store = memento_options_store.merge(options)
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
data/lib/memento/version.rb
CHANGED
data/lib/memento.rb
CHANGED
@@ -35,6 +35,10 @@ describe Memento::ActiveRecordMethods do
|
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
38
|
+
it "should set memento_options" do
|
39
|
+
Project.memento_options.should eql({:ignore=>[:ignore_this]})
|
40
|
+
end
|
41
|
+
|
38
42
|
it "should define changes_for_memento and ignore attributes given by options" do
|
39
43
|
project = Project.create!(:name => "Project X")
|
40
44
|
project.name = "A Project"
|
metadata
CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.3.4
|
8
|
+
- 5
|
9
|
+
version: 0.3.5
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Yolk Sebastian Munz & Julia Soergel GbR
|
@@ -15,11 +14,12 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date:
|
17
|
+
date: 2012-02-06 00:00:00 +01:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: activerecord
|
22
|
+
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
@@ -28,13 +28,12 @@ dependencies:
|
|
28
28
|
segments:
|
29
29
|
- 3
|
30
30
|
- 0
|
31
|
-
segments_generated: true
|
32
31
|
version: "3.0"
|
33
32
|
type: :runtime
|
34
|
-
prerelease: false
|
35
33
|
version_requirements: *id001
|
36
34
|
- !ruby/object:Gem::Dependency
|
37
35
|
name: actionpack
|
36
|
+
prerelease: false
|
38
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
40
39
|
requirements:
|
@@ -43,13 +42,12 @@ dependencies:
|
|
43
42
|
segments:
|
44
43
|
- 3
|
45
44
|
- 0
|
46
|
-
segments_generated: true
|
47
45
|
version: "3.0"
|
48
46
|
type: :runtime
|
49
|
-
prerelease: false
|
50
47
|
version_requirements: *id002
|
51
48
|
- !ruby/object:Gem::Dependency
|
52
49
|
name: rspec
|
50
|
+
prerelease: false
|
53
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
52
|
none: false
|
55
53
|
requirements:
|
@@ -59,13 +57,12 @@ dependencies:
|
|
59
57
|
- 2
|
60
58
|
- 4
|
61
59
|
- 0
|
62
|
-
segments_generated: true
|
63
60
|
version: 2.4.0
|
64
61
|
type: :development
|
65
|
-
prerelease: false
|
66
62
|
version_requirements: *id003
|
67
63
|
- !ruby/object:Gem::Dependency
|
68
64
|
name: sqlite3
|
65
|
+
prerelease: false
|
69
66
|
requirement: &id004 !ruby/object:Gem::Requirement
|
70
67
|
none: false
|
71
68
|
requirements:
|
@@ -75,10 +72,8 @@ dependencies:
|
|
75
72
|
- 1
|
76
73
|
- 3
|
77
74
|
- 3
|
78
|
-
segments_generated: true
|
79
75
|
version: 1.3.3
|
80
76
|
type: :development
|
81
|
-
prerelease: false
|
82
77
|
version_requirements: *id004
|
83
78
|
description: Undo for Rails/ActiveRecord - covers destroy, update and create
|
84
79
|
email: sebastian@yo.lk
|
@@ -90,6 +85,7 @@ extra_rdoc_files: []
|
|
90
85
|
|
91
86
|
files:
|
92
87
|
- .gitignore
|
88
|
+
- CHANGES.md
|
93
89
|
- Gemfile
|
94
90
|
- LICENSE
|
95
91
|
- README.rdoc
|
@@ -134,20 +130,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
130
|
requirements:
|
135
131
|
- - ">="
|
136
132
|
- !ruby/object:Gem::Version
|
137
|
-
hash: -4150374159441153301
|
138
133
|
segments:
|
139
134
|
- 0
|
140
|
-
segments_generated: true
|
141
135
|
version: "0"
|
142
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
137
|
none: false
|
144
138
|
requirements:
|
145
139
|
- - ">="
|
146
140
|
- !ruby/object:Gem::Version
|
147
|
-
hash: -4150374159441153301
|
148
141
|
segments:
|
149
142
|
- 0
|
150
|
-
segments_generated: true
|
151
143
|
version: "0"
|
152
144
|
requirements: []
|
153
145
|
|