diff options
| author | Stefan Daschek <[email protected]> | 2013-07-08 16:34:28 +0200 |
|---|---|---|
| committer | Stefan Daschek <[email protected]> | 2013-07-08 16:34:28 +0200 |
| commit | 2a4c39f7ae863ac7e4d14e0110aba11fce4a822f (patch) | |
| tree | 5066098e520ba7a5d50d36eb0f39f20a5266fd84 | |
| parent | 92b73ffb1e5cdfb001da684c463856f79aff6e11 (diff) | |
| download | caxlsx-2a4c39f7ae863ac7e4d14e0110aba11fce4a822f.tar.gz caxlsx-2a4c39f7ae863ac7e4d14e0110aba11fce4a822f.zip | |
Simply Relationship.next_free_id by depending on number of cached instances.
Only drawback: Setting @next_freed_id_counter to 1000 in tc_helper.rb is no longer possible. But this was useful mainly while adding / fixing test cases when implementing the Relationship instance cache.
| -rw-r--r-- | lib/axlsx/rels/relationship.rb | 4 | ||||
| -rw-r--r-- | test/tc_helper.rb | 4 |
2 files changed, 1 insertions, 7 deletions
diff --git a/lib/axlsx/rels/relationship.rb b/lib/axlsx/rels/relationship.rb index 64356d46..5e75a98a 100644 --- a/lib/axlsx/rels/relationship.rb +++ b/lib/axlsx/rels/relationship.rb @@ -14,9 +14,7 @@ module Axlsx # Generate and return a unique id. Used for setting {#Id}. # @return [String] def next_free_id - @next_free_id_counter ||= 0 - @next_free_id_counter += 1 - "rId#{@next_free_id_counter}" + "rId#{@instances.size + 1}" end end diff --git a/test/tc_helper.rb b/test/tc_helper.rb index c09446b7..af40a1e4 100644 --- a/test/tc_helper.rb +++ b/test/tc_helper.rb @@ -8,7 +8,3 @@ end require 'test/unit' require "timecop" require "axlsx.rb" - -# Make sure all valid rIds are > 1000 - this should help catching the cases where rId is still -# determined by looking at the index of an object in an array etc. -Axlsx::Relationship.instance_variable_set :@next_free_id_counter, 1000 |
