File: blank_slate.rb

package info (click to toggle)
ruby-rr 3.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,424 kB
  • sloc: ruby: 11,405; makefile: 7
file content (17 lines) | stat: -rw-r--r-- 547 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module RR
  module BlankSlate
    extend(Module.new do
      def call(klass)
        klass.instance_eval do
          instance_methods.each do |unformatted_method_name|
            method_name = unformatted_method_name.to_s
            unless method_name =~ /^_/ || Space.blank_slate_whitelist.any? {|whitelisted_method_name| method_name == whitelisted_method_name}
              alias_method "__blank_slated_#{method_name}", method_name
              undef_method method_name
            end
          end
        end
      end
    end)
  end
end