Created
February 20, 2010 20:40
-
-
Save thumblemonks/309894 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RiotRails | |
register_context_helper do | |
def prepare_context(description, context) | |
context.premium_setup { description.new } if active_record_context?(description) | |
context.transaction do |&original_block| | |
::ActiveRecord::Base.transaction do | |
original_block.call | |
raise ::ActiveRecord::Rollback | |
end | |
end | |
end | |
private | |
def active_record_context?(description) | |
description.kind_of?(Class) && description.ancestors.include?(::ActiveRecord::Base) | |
end | |
end | |
end # RiotRails |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment