txus-aversion 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/aversion.rb +14 -9
  2. data/lib/aversion/version.rb +1 -1
  3. metadata +2 -2
@@ -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
- @transformations = []
54
- @initial_args = args
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(*@initial_args).tap do |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.instance_variable_set(:@transformations, @transformations.dup)
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(*@initial_args).tap do |instance|
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
- @transformations
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
- @transformations = transformations
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
- @initial_args == other.instance_variable_get(:@initial_args) &&
129
- history == other.history
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
@@ -1,3 +1,3 @@
1
1
  module Aversion
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-10-20 00:00:00.000000000 Z
12
+ date: 2012-12-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Make your Ruby objects versionable
15
15
  email: