module Transactify::ClassMethods
Public Instance Methods
ctransactify(*cmethods)
click to toggle source
Calls superclass method
# File lib/transactify.rb, line 16 def ctransactify(*cmethods) interceptor = const_get("#{name.demodulize}Interceptor") klass = const_get(name) helper = const_set("Transactify#{SecureRandom.hex}Helper", Module.new) cmethods.each do |method_name| interceptor.module_eval do helper.send :define_singleton_method, :prepended do |base| define_method(method_name) do |*args, &block| ActiveRecord::Base.transaction do super(*args, &block) end end end (class << klass; self; end).module_eval do prepend(helper) end end end end
transactify(*cmethods)
click to toggle source
Calls superclass method
# File lib/transactify.rb, line 36 def transactify(*cmethods) interceptor = const_get("#{name.demodulize}Interceptor") cmethods.each do |method_name| interceptor.module_eval do define_method(method_name) do |*args, &block| ActiveRecord::Base.transaction do super(*args, &block) end end end end end