Module: Cell::Ext::Migration::ContextTracker
- Defined in:
- lib/cell/ext/migration.rb
Overview
OK, ContextTracker keeps up with:
* The context in which this migration is being ran, e.g. the :global first pass, the
:prototype second pass, OR the :targeted per tenant pass.
* If it's in a global block or not, which determines if actions are actually executed
* If force_execution is set, which is for the benefit of playing back CommandRecorder
commands.
Instance Method Summary collapse
- #execute_ddl? ⇒ Boolean
-
#force_call(*args, &block) ⇒ Object
When the CommandRecorder’s commands are executed, they’re rewritten to go through force_call, because the “effective set of commands” have already been determined by the CommandRecorder run.
- #global ⇒ Object
- #with_context(context, search_path, exclusive: false) ⇒ Object
Instance Method Details
#execute_ddl? ⇒ Boolean
39 40 41 42 43 44 |
# File 'lib/cell/ext/migration.rb', line 39 def execute_ddl? force_execution || (pass_context == :global && global_block) || (pass_context == :prototype && !global_block) || (pass_context == :target && !global_block) end |
#force_call(*args, &block) ⇒ Object
When the CommandRecorder’s commands are executed, they’re rewritten to go through force_call, because the “effective set of commands” have already been determined by the CommandRecorder run.
49 50 51 52 53 54 |
# File 'lib/cell/ext/migration.rb', line 49 def force_call(*args, &block) saved, self.force_execution = self.force_execution, true send(*args, &block) ensure self.force_execution = saved end |
#global ⇒ Object
67 68 69 70 71 72 |
# File 'lib/cell/ext/migration.rb', line 67 def global saved, self.global_block = self.global_block, true yield ensure self.global_block = saved end |
#with_context(context, search_path, exclusive: false) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cell/ext/migration.rb', line 56 def with_context(context, search_path, exclusive: false) Meta::with_schema(search_path, exclusive: exclusive) do begin saved, self.pass_context = self.pass_context, context yield ensure self.pass_context = saved end end end |