dm-aux_codes 1.0.8 → 1.0.9

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.
Files changed (2) hide show
  1. data/lib/aux_codes.rb +9 -5
  2. metadata +2 -2
data/lib/aux_codes.rb CHANGED
@@ -172,7 +172,7 @@ module Stuff
172
172
 
173
173
  def create_classes!
174
174
  AuxCode.categories.each do |category|
175
- Object.const_set category.class_name, category.aux_code_class
175
+ Object.const_set category.class_name, category.aux_code_class unless Object.const_defined?(category.class_name)
176
176
  end
177
177
  end
178
178
 
@@ -208,10 +208,7 @@ module Stuff
208
208
  # initialize AuxCodes ... looks for config/aux_codes.yml
209
209
  # and creates classes
210
210
  def init # should eventually take configuration options (hash || block)
211
- # If there isn't an AuxCode yet, make one with the ID of 0.
212
- # This makes database foreign key constraints stop complaining
213
- # when we create aux codes where the aux_code_id is 0.
214
- AuxCode.create :id => 0, :name => 'Aux Code Categories' if AuxCode.count == 0
211
+ create_root_code!
215
212
  aux_codes_yml = File.join 'config', 'aux_codes.yml'
216
213
  if File.file? aux_codes_yml
217
214
  load_file aux_codes_yml
@@ -219,6 +216,13 @@ module Stuff
219
216
  end
220
217
  end
221
218
 
219
+ def create_root_code!
220
+ # If there isn't an AuxCode yet, make one with the ID of 0.
221
+ # This makes database foreign key constraints stop complaining
222
+ # when we create aux codes where the aux_code_id is 0.
223
+ AuxCode.create :id => 0, :name => 'Aux Code Categories' unless AuxCode.get(0)
224
+ end
225
+
222
226
  #
223
227
  # loads AuxCodes (creates them) from a Hash, keyed on the name of the aux code categories to create
224
228
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-aux_codes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - remi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-21 00:00:00 -07:00
12
+ date: 2010-01-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15