Sha256: 2f80cba62d683ab4a9cfdc3cfefe1dbfbbaa26f63ef1b964a6324ec7e105a36d

Contents?: true

Size: 460 Bytes

Versions: 1

Compression:

Stored size: 460 Bytes

Contents

require "forewarn/triggers_warning"

module Forewarn
  class OverridesMethods
    def override!(methods)
      triggers_warning = TriggersWarning.new
      methods.each do |method|
        real_method = method.method
        real_method.owner.send(:define_method, real_method.name) do |*args, &blk|
          triggers_warning.trigger!(method, caller_locations(1,1)[0].to_s)
          method.bind(self).call(*args, &blk)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
forewarn-0.1.0 lib/forewarn/overrides_methods.rb