Class: CleanActions::IsolationLevelValidator
- Inherits:
-
Object
- Object
- CleanActions::IsolationLevelValidator
- Defined in:
- lib/clean_actions/isolation_level_validator.rb
Constant Summary collapse
- VALID_ISOLATION_LEVELS =
i[read_uncommited read_committed repeatable_read]
Class Method Summary collapse
- .can_be_nested(isolation_level) ⇒ Object
- .validate(isolation_level, allow_serializable: false) ⇒ Object
Class Method Details
.can_be_nested(isolation_level) ⇒ Object
20 21 22 23 |
# File 'lib/clean_actions/isolation_level_validator.rb', line 20 def can_be_nested(isolation_level) CleanActions.config.isolation_level == :serializable || VALID_ISOLATION_LEVELS.index(isolation_level) <= VALID_ISOLATION_LEVELS.index(Thread.current[:root_isolation_level]) end |
.validate(isolation_level, allow_serializable: false) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/clean_actions/isolation_level_validator.rb', line 6 def validate(isolation_level, allow_serializable: false) if isolation_level == :serializable unless allow_serializable ErrorReporter.report("serializable isolation should only be used for a whole project, please use global config") end return end return if VALID_ISOLATION_LEVELS.include?(isolation_level) ErrorReporter.report("invalid isolation level #{isolation_level} for #{name}") end |