ztk 1.6.15 → 1.6.16

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.
@@ -14,7 +14,7 @@ module ZTK
14
14
  # Formats a header suitable for writing to the direct logger when logging
15
15
  # sessions.
16
16
  def log_header(what)
17
- count = 8
17
+ count = 12
18
18
  sep = ("=" * count)
19
19
  header = [sep, "[ #{what} ]", sep, "[ #{tag} ]", sep, "[ #{what} ]", sep].join
20
20
  "#{header}\n"
@@ -151,15 +151,15 @@ module ZTK::DSL
151
151
  end
152
152
 
153
153
  def initialize(id=nil, &block)
154
- self.id = (id || self.class.id)
155
- self.class.dataset.delete_if{ |d| d.id == self.id }
154
+ self.id = (id || self.class.next_id)
156
155
  self.class.dataset << self
156
+
157
157
  block_given? and ((block.arity < 1) ? instance_eval(&block) : block.call(self))
158
158
 
159
- # primary_key_count = self.class.dataset.count do |d|
160
- # d.id == self.id
161
- # end
162
- # raise StandardError, "Primary key '#{self.id}' already exists!" if (primary_key_count > 1)
159
+ primary_key_count = self.class.dataset.count do |d|
160
+ d.id == self.id
161
+ end
162
+ raise StandardError, "Primary key '#{self.id}' already exists!" if (primary_key_count > 1)
163
163
  end
164
164
 
165
165
  # Instance Inspect
@@ -12,7 +12,6 @@ module ZTK::DSL::Core
12
12
 
13
13
  # @author Zachary Patten <zachary AT jovelabs DOT com>
14
14
  module ClassMethods
15
-
16
15
  def dataset
17
16
  klass = self.to_s.underscore.to_sym
18
17
  @@dataset ||= {}
@@ -27,9 +26,13 @@ module ZTK::DSL::Core
27
26
  @@dataset = nil
28
27
  end
29
28
 
30
- def id
31
- @@id ||= 0
32
- (@@id += 1)
29
+ def next_id
30
+ klass = self.to_s.underscore.to_sym
31
+ @@id ||= {}
32
+ @@id[klass] ||= 0
33
+
34
+ @@id[klass] += 1
35
+ @@id[klass]
33
36
  end
34
37
 
35
38
  end
@@ -1,6 +1,6 @@
1
1
  module ZTK
2
2
 
3
3
  # ZTK Version String
4
- VERSION = "1.6.15"
4
+ VERSION = "1.6.16"
5
5
 
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ztk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.15
4
+ version: 1.6.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -275,7 +275,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
275
275
  version: '0'
276
276
  segments:
277
277
  - 0
278
- hash: -2199725361471494570
278
+ hash: 3831905173950647033
279
279
  required_rubygems_version: !ruby/object:Gem::Requirement
280
280
  none: false
281
281
  requirements:
@@ -284,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
284
  version: '0'
285
285
  segments:
286
286
  - 0
287
- hash: -2199725361471494570
287
+ hash: 3831905173950647033
288
288
  requirements: []
289
289
  rubyforge_project:
290
290
  rubygems_version: 1.8.25