Created
December 10, 2010 07:17
-
-
Save moro/735901 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ImportUtil | |
module ClassMethods | |
def inside_import? | |
Thread.current[:inside_import] | |
end | |
def step_into_import | |
t = Thread.current[:inside_import] | |
begin | |
Thread.current[:inside_import] = true | |
yield | |
ensure | |
Thread.current[:inside_import] = t | |
end | |
end | |
end | |
def inside_import? | |
self.class.inside_import? | |
end | |
# usage | |
after_save :unless => :inside_import? do | |
Rails.logger.debug("moro") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment