Sha256: 2cccec093395d695f2e5493ddf4eea2ae016170b5c37fd162a96e8db57a61bdf
Contents?: true
Size: 588 Bytes
Versions: 1
Compression:
Stored size: 588 Bytes
Contents
require "lier/version" module Lier klasses = ObjectSpace.each_object(Module).reject do |k| k.singleton_class? || k.to_s.start_with?('#') end.sort_by(&:to_s) klasses.each do |k| methods = k.instance_methods(false).select { |m| m.to_s.end_with?('?') } - [:respond_to?] next if methods.empty? code = "refine #{k} do\n" code += methods.map do |name| <<-EOF alias_method :_#{name}, :#{name} def #{name}(*args, &block) !_#{name}(*args, &block) end EOF end.join("\n") code += "\nend" eval(code) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lier-0.1.0 | lib/lier.rb |