Created
November 15, 2017 03:30
-
-
Save dulao5/ee8b8fe778e80aab4e554bfb1badebe9 to your computer and use it in GitHub Desktop.
dry_run plugin
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
class ClassA | |
class << self | |
def sendtouser(id, id2) | |
puts "origin sendtouser #{id} #{id2}" | |
end | |
end | |
end | |
module DryRunModule | |
class << self | |
def plug_dry_run | |
ClassA.singleton_class.class_eval do | |
attr_accessor :dry_run | |
alias_method :original_sendtouser, :sendtouser | |
def sendtouser(id, id2) | |
puts "dryrun fun : #{dry_run} :sendtouser #{id} #{id2}" | |
original_sendtouser(id, id2) unless dry_run | |
end | |
end | |
end | |
end | |
end | |
DryRunModule.plug_dry_run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment