Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module SWrapper
- def self.included(base)
- base.send(:include, Wrap)
- target = "find"
- feature= "wrapping"
- base.send(:alias_method, "#{target}_without_#{feature}", target)
- base.send(:alias_method, target, "#{target}_with_#{feature}")
- end
- module Wrap
- def find_with_wrapping(*args, &block)
- puts "Test"
- find_without_wrapping(*args, &block)
- end
- end
- end
- class Person < ActiveRecord::Base
- include SWrapper
- end
- doing Person.find 999999999 --> #<NameError: undefined method `find' for class `Person'>
Add Comment
Please, Sign In to add comment