culturecode_stagehand 0.15.0 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9d9b08d666b45682ff43da53ba2086f89cd9a5c
4
- data.tar.gz: 70088b1cea4eecd3f9ecfc2837c596f8b3c47b53
3
+ metadata.gz: 5fdc23b385dbb657b54cb029e4714657b4aa3e69
4
+ data.tar.gz: bdbd449b63397e6a68e223616d1ee6f7ce737c58
5
5
  SHA512:
6
- metadata.gz: 6d39beaebb5322b8b48f346856c433c60ac6cdd7d6c439f6e90155a8945129e1a89d5971faa353b48545575354bbc9ab6b976bb1a9157ce25a08d7c754ebc0f7
7
- data.tar.gz: e062f7ad0a92320c091374c8379b41f2de395a118a3acbbe1311dc2d4dfc5e616be163cbb6b8cd6ec853589cbfaacf974f72a37f1e5b6b595d40433e6bfa9766
6
+ metadata.gz: 87fb81e17c7fb2837b9217bc7cda6758b1694667f1b5b0a97da5b75bb0c512fe2a695d2ee44768d8e3ceb275d07f222453d7eb79ad69dd98426156df021f4cbe
7
+ data.tar.gz: ab28c8a9ab9cc625c30a573c17c2e4043d9498aef2f9cf90e01bcba2ed9d68d91c0d1708d59f2df27905cf6644617e1e99a6bd41d626d1ff7902f32209db7662
@@ -17,4 +17,10 @@ ActiveRecord::Base.class_eval do
17
17
  end
18
18
  end
19
19
  end
20
+
21
+ # SCHEMA
22
+ delegate :has_stagehand?, to: :class
23
+ def self.has_stagehand?
24
+ @has_stagehand ||= Stagehand::Schema.has_stagehand?(table_name)
25
+ end
20
26
  end
@@ -50,7 +50,7 @@ module Stagehand
50
50
  end
51
51
 
52
52
  def with_connection(connection_name)
53
- different = database_name(current_connection_name) != database_name(connection_name)
53
+ different = current_connection_name != connection_name.to_sym
54
54
 
55
55
  if different
56
56
  @@connection_name_stack.push(connection_name.to_sym)
@@ -21,7 +21,7 @@ module Stagehand
21
21
  begin
22
22
  block.call(start_operation)
23
23
  rescue => e
24
- end_commit(start_operation, except)
24
+ end_commit(start_operation, except) unless e.is_a?(CommitError)
25
25
  raise(e)
26
26
  else
27
27
  return end_commit(start_operation, except)
@@ -50,7 +50,10 @@ module Stagehand
50
50
 
51
51
  # Make it easy to set the subject for the duration of the commit block
52
52
  def start_operation.subject=(record)
53
- self.assign_attributes :record_id => record.id, :table_name => record.class.table_name if record && record.id
53
+ if record&.id
54
+ raise NonStagehandSubject unless record.has_stagehand?
55
+ self.assign_attributes :record_id => record.id, :table_name => record.class.table_name
56
+ end
54
57
  save!
55
58
  end
56
59
 
@@ -137,6 +140,8 @@ module Stagehand
137
140
  end
138
141
 
139
142
  # EXCEPTIONS
140
- class CommitNotFound < StandardError; end
141
- class BlankCommitEntrySession < StandardError; end
143
+ class CommitError < StandardError; end
144
+ class CommitNotFound < CommitError; end
145
+ class BlankCommitEntrySession < CommitError; end
146
+ class NonStagehandSubject < CommitError; end
142
147
  end
@@ -1,3 +1,3 @@
1
1
  module Stagehand
2
- VERSION = "0.15.0"
2
+ VERSION = "0.15.1"
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.15.0
4
+ version: 0.15.1
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: 2017-11-06 00:00:00.000000000 Z
12
+ date: 2017-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails