Created
April 28, 2009 02:28
-
-
Save wagenet/102891 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
require 'proxy_block' | |
module WithoutTimestamps | |
def self.included(base) | |
base.send :extend, ClassMethods | |
base.send :include, InstanceMethods | |
class << base; proxy_block :without_timestamps; end | |
base.send :proxy_block, :without_timestamps | |
end | |
module ClassMethods | |
def without_timestamps | |
original = self.record_timestamps | |
self.record_timestamps = false | |
yield | |
ensure | |
self.record_timestamps = original | |
end | |
end | |
module InstanceMethods | |
def without_timestamps(&block) | |
self.class.without_timestamps(&block) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment