Skip to content

Instantly share code, notes, and snippets.

@moro
Created December 10, 2010 07:17
Show Gist options
  • Save moro/735901 to your computer and use it in GitHub Desktop.
Save moro/735901 to your computer and use it in GitHub Desktop.
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