class MonkeyPatcher class << self MONKEY_PATCHES = Rails.root.join('lib', 'monkey_patches') def run(&) patches = Dir.glob(MONKEY_PATCHES.join('**', '*.rb')) patches.each do |patch| file = Pathname.new(patch).relative_path_from(MONKEY_PATCHES).to_s next if file == 'monkey_patcher.rb' # filter off its own file! if !block_given? || yield(file) puts "🐵 patching... #{file}" require file end end end end end