tomriley-previous_changes 0.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/README +11 -0
- data/init.rb +1 -0
- data/lib/previous_changes.rb +19 -0
- metadata +63 -0
data/README
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Very simple Rails plugin that adds the method 'previous_changes' to ActiveRecord objects that can be called after saving a model object to fetch what the method 'changes' would have returned just before the save occurred (a hash from attribute name to a pair of values - the old attribute value and the new attribute value).
|
2
|
+
|
3
|
+
Installation
|
4
|
+
------------
|
5
|
+
|
6
|
+
$ gem sources -a http://gems.github.com (you only have to do this once)
|
7
|
+
$ sudo gem install tomriley-previous_changes
|
8
|
+
|
9
|
+
Then add a dependency to your rails environment.rb:
|
10
|
+
|
11
|
+
config.gem 'tomriley-previous_changes', :lib => 'previous_changes', :version => '0.0.1'
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'previous_changes'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module PreviousChanges
|
2
|
+
module Extensions
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
after_validation_on_update :save_changes
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def save_changes
|
10
|
+
@previous_changes = changes
|
11
|
+
end
|
12
|
+
|
13
|
+
def previous_changes
|
14
|
+
@previous_changes
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ActiveRecord::Base.class_eval { include PreviousChanges::Extensions }
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tomriley-previous_changes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Riley
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-24 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activerecord
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description: An ActiveRecord plugin that provides a previous_changes method to fetch changes made during the last save operation
|
25
|
+
email: tom@smallroomsoftware.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- README
|
34
|
+
- init.rb
|
35
|
+
- lib/previous_changes.rb
|
36
|
+
has_rdoc: false
|
37
|
+
homepage: http://github.com/tomriley/previous_changes/
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
requirements: []
|
56
|
+
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.2.0
|
59
|
+
signing_key:
|
60
|
+
specification_version: 2
|
61
|
+
summary: An ActiveRecord plugin that provides a previous_changes method to fetch changes made during the last save operation
|
62
|
+
test_files: []
|
63
|
+
|