txus-aversion 0.0.1 → 0.0.2
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/lib/aversion.rb +14 -9
- data/lib/aversion/version.rb +1 -1
- metadata +2 -2
data/lib/aversion.rb
CHANGED
@@ -50,8 +50,8 @@ module Aversion
|
|
50
50
|
allocate.tap do |instance|
|
51
51
|
instance.send :initialize, *args
|
52
52
|
instance.instance_eval do
|
53
|
-
|
54
|
-
@
|
53
|
+
self.history = []
|
54
|
+
@__initial_args__ = args
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -61,10 +61,10 @@ module Aversion
|
|
61
61
|
# Public: Returns a mutable version of the object, in case anyone needs it. We
|
62
62
|
# do need it internally to perform transformations.
|
63
63
|
def mutable
|
64
|
-
self.class.new_mutable(
|
64
|
+
self.class.new_mutable(*initial_args).tap do |mutable|
|
65
65
|
instance_variables.each do |ivar|
|
66
66
|
mutable.instance_variable_set(ivar, instance_variable_get(ivar))
|
67
|
-
mutable.
|
67
|
+
mutable.history = history.dup
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -82,7 +82,7 @@ module Aversion
|
|
82
82
|
#
|
83
83
|
# Returns a new, immutable copy with the previous state.
|
84
84
|
def rollback
|
85
|
-
self.class.new_mutable(
|
85
|
+
self.class.new_mutable(*initial_args).tap do |instance|
|
86
86
|
instance.replay(history[0..-2])
|
87
87
|
end.freeze
|
88
88
|
end
|
@@ -103,13 +103,13 @@ module Aversion
|
|
103
103
|
|
104
104
|
# Internal: Returns the history of this object.
|
105
105
|
def history
|
106
|
-
@
|
106
|
+
@__transformations__
|
107
107
|
end
|
108
108
|
|
109
109
|
# Internal: Sets the history of this object to a specific array fo
|
110
110
|
# transformations.
|
111
111
|
def history=(transformations)
|
112
|
-
@
|
112
|
+
@__transformations__ = transformations
|
113
113
|
end
|
114
114
|
|
115
115
|
# Public: Returns the difference between two versioned objects, which is an
|
@@ -125,7 +125,12 @@ module Aversion
|
|
125
125
|
# They will be equal as long as they have the same initial args with they were
|
126
126
|
# constructed with and their history is the same.
|
127
127
|
def ==(other)
|
128
|
-
|
129
|
-
|
128
|
+
initial_args == other.initial_args && history == other.history
|
129
|
+
end
|
130
|
+
|
131
|
+
# Public: Exposes the initial arguments passed to the constructor, for
|
132
|
+
# comparison purposes.
|
133
|
+
def initial_args
|
134
|
+
@__initial_args__
|
130
135
|
end
|
131
136
|
end
|
data/lib/aversion/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: txus-aversion
|
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,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Make your Ruby objects versionable
|
15
15
|
email:
|