culturecode_stagehand 0.7.13 → 0.7.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a6d79d7749da33008302addc5f4ab7b6ef3f53a
4
- data.tar.gz: b939f07f252406b5ce2c06eba0cbc968d79836d8
3
+ metadata.gz: ac363341da8677b3c1cfd520613c84e0867f3ad2
4
+ data.tar.gz: 9589806d9dd238748cc953f54f411ef442a8d63c
5
5
  SHA512:
6
- metadata.gz: 9bb90a7ba80ea273602a4d56e8d0d8b22495ed253e9c94444c14d8101c4e2dabbb65e144766decd57a5247ed53b0a7ba8f6b0e3a9c1b67706eed3b45cfce1f2f
7
- data.tar.gz: 65a6462d3e10ff7ccbb18feb8d437cd409da00eba68901c3522c0149586b53da089e762c510cb712639e66265ad61ee2ca8317bf29653fdc9df21bf39c44fa88
6
+ metadata.gz: 54f5ea80bac184c901919d16e9832a2c7b09b208916ab92f744d783dd9079d8af88609e92b568bbe705a75f20ada6d708caf6bebf5db15c07681f2cc437b3c77
7
+ data.tar.gz: bdac04efe1e754db2a006a6bb86ec6ef09e192d00066ba969f6dd8260a7b54daf67b8d777cac8a0e574528188e27c607cadc1d0c5b2a224723893680e7d4b817
@@ -17,9 +17,8 @@ module Stagehand
17
17
  end
18
18
 
19
19
  add_index :stagehand_commit_entries, :commit_id # Used for looking up all entries within a commit
20
- add_index :stagehand_commit_entries, :operation # Mostly used for looking up start entries
21
20
  add_index :stagehand_commit_entries, [:record_id, :table_name] # Used for 'matching' scope
22
- add_index :stagehand_commit_entries, [:operation, :commit_id] # Used for 'not_in_progress' scope
21
+ add_index :stagehand_commit_entries, [:operation, :commit_id] # Used for looking up start entries, and 'not_in_progress' scope
23
22
 
24
23
  # Create trigger to initialize session using a function
25
24
  ActiveRecord::Base.connection.execute("DROP TRIGGER IF EXISTS stagehand_session_trigger;")
@@ -115,6 +115,8 @@ module Stagehand
115
115
 
116
116
  def record_class
117
117
  @record_class ||= self.class.infer_class(table_name, record_id)
118
+ rescue IndeterminateRecordClass
119
+ @record_class ||= self.class.build_missing_model(table_name)
118
120
  end
119
121
 
120
122
  private
@@ -130,9 +132,15 @@ module Stagehand
130
132
 
131
133
  return deleted_record
132
134
  end
135
+
136
+ def self.build_missing_model(table_name)
137
+ raise MissingTable, "Can't find table specified in entry: #{table_name}" unless Database.staging_connection.tables.include?(table_name)
138
+ Object.const_set(table_name.classify, Class.new(ActiveRecord::Base))
139
+ end
133
140
  end
134
141
  end
135
142
 
136
143
  # EXCEPTIONS
137
144
  class IndeterminateRecordClass < StandardError; end
145
+ class MissingTable < StandardError; end
138
146
  end
@@ -1,3 +1,3 @@
1
1
  module Stagehand
2
- VERSION = "0.7.13"
2
+ VERSION = "0.7.14"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: culturecode_stagehand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.13
4
+ version: 0.7.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-15 00:00:00.000000000 Z
12
+ date: 2016-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails