track_history 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/lib/track_history.rb CHANGED
@@ -27,10 +27,6 @@ module TrackHistory
27
27
  @klass_reference
28
28
  end
29
29
 
30
- def historical_fields
31
- @klass_reference.historical_fields.keys
32
- end
33
-
34
30
  private
35
31
 
36
32
  def define_historical_model(base, model_name, table_name, track_reference, &block)
@@ -38,12 +34,17 @@ module TrackHistory
38
34
  # figure out the model name
39
35
  model_name ||= "#{base.name}History"
40
36
  @klass_reference = Object.const_set(model_name, Class.new(ActiveRecord::Base))
37
+ @klass_reference.send(:table_name=, table_name) unless table_name.nil?
38
+
39
+ unless @klass_reference.table_exists?
40
+ STDERR.puts "[TrackHistory] No such table exists: #{@klass_reference.table_name}"
41
+ return
42
+ end
41
43
 
42
44
  # get the history class in line
43
45
  @klass_reference.send(:extend, HistoryMethods)
44
46
 
45
47
  # infer fields
46
- @klass_reference.send(:table_name=, table_name) unless table_name.nil?
47
48
  @klass_reference.columns_hash.each_key do |k|
48
49
  matches = k.match(/(.+?)_before$/)
49
50
  if matches && matches.size == 2 && field_name = matches[1]
@@ -1,5 +1,5 @@
1
1
  module TrackHistory
2
2
 
3
- VERSION = '0.0.8'
3
+ VERSION = '0.0.9'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: track_history
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Crepezzi