Module: Lev::Routine::ClassMethods
- Defined in:
- lib/lev/routine.rb
Instance Method Summary collapse
- #call(*args, &block) ⇒ Object
- #class_to_symbol(klass) ⇒ Object
- #nested_routines ⇒ Object
- #transaction_isolation ⇒ Object
-
#uses_routine(routine_class, options = {}) ⇒ Object
Called at a routine’s class level to foretell which other routines will be used when this routine executes.
Instance Method Details
#call(*args, &block) ⇒ Object
199 200 201 |
# File 'lib/lev/routine.rb', line 199 def call(*args, &block) new.call(*args, &block) end |
#class_to_symbol(klass) ⇒ Object
228 229 230 |
# File 'lib/lev/routine.rb', line 228 def class_to_symbol(klass) klass.name.underscore.gsub('/','_').to_sym end |
#nested_routines ⇒ Object
224 225 226 |
# File 'lib/lev/routine.rb', line 224 def nested_routines @nested_routines ||= {} end |
#transaction_isolation ⇒ Object
220 221 222 |
# File 'lib/lev/routine.rb', line 220 def transaction_isolation @transaction_isolation ||= TransactionIsolation.mysql_default end |
#uses_routine(routine_class, options = {}) ⇒ Object
Called at a routine’s class level to foretell which other routines will be used when this routine executes. Helpful for figuring out ahead of time what kind of transaction isolation level should be used.
206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/lev/routine.rb', line 206 def uses_routine(routine_class, ={}) symbol = [:as] || class_to_symbol(routine_class) raise IllegalArgument, "Routine #{routine_class} has already been registered" \ if nested_routines[symbol] nested_routines[symbol] = { routine_class: routine_class, options: } transaction_isolation.replace_if_more_isolated(routine_class.transaction_isolation) end |