Class: Txray::ScopeFinder
- Inherits:
-
Object
- Object
- Txray::ScopeFinder
- Defined in:
- lib/txray/transaction_scope.rb
Constant Summary collapse
- LOCK_BLOCKS =
%i[with_lock with_advisory_lock].freeze
Instance Method Summary collapse
- #call(source) ⇒ Object
-
#initialize(index) ⇒ ScopeFinder
constructor
A new instance of ScopeFinder.
Constructor Details
#initialize(index) ⇒ ScopeFinder
Returns a new instance of ScopeFinder.
11 12 13 |
# File 'lib/txray/transaction_scope.rb', line 11 def initialize(index) @index = index end |
Instance Method Details
#call(source) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/txray/transaction_scope.rb', line 15 def call(source) migrations = Set.new modules = Set.new scopes = [] Namespaces.each(source.root) do |namespace, node| case node when Prism::ClassNode then migrations << namespace if transactional_migration?(node) when Prism::ModuleNode then modules << namespace when Prism::CallNode then scopes.concat(from_call(namespace, node, source, modules)) when Prism::DefNode then scopes.concat(from_definition(namespace, node, source, migrations)) end end scopes.compact end |