Sha256: 00d54ce7d1ca057c27225ffd6a5936d788946f8158f51f12abcfcfa8982131a7

Contents?: true

Size: 771 Bytes

Versions: 23

Compression:

Stored size: 771 Bytes

Contents

# frozen_string_literal: true

module Switchman
  module CallSuper
    def super_method_above(method_name, above_module)
      method = method(method_name)
      last_owner = method.owner
      while method.owner != above_module
        method = method.super_method
        raise "Could not find super method ``#{method_name}' for #{self.class}" if method.owner == last_owner
      end
      method.super_method
    end

    if RUBY_VERSION <= "2.8"
      def call_super(method, above_module, *args, &block)
        super_method_above(method, above_module).call(*args, &block)
      end
    else
      def call_super(method, above_module, *args, **kwargs, &block)
        super_method_above(method, above_module).call(*args, **kwargs, &block)
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
switchman-3.5.22 lib/switchman/call_super.rb
switchman-3.5.21 lib/switchman/call_super.rb
switchman-3.5.20 lib/switchman/call_super.rb
switchman-3.5.19 lib/switchman/call_super.rb
switchman-3.5.18 lib/switchman/call_super.rb
switchman-3.5.17 lib/switchman/call_super.rb
switchman-3.5.16 lib/switchman/call_super.rb
switchman-3.5.15 lib/switchman/call_super.rb
switchman-3.5.14 lib/switchman/call_super.rb
switchman-3.5.13 lib/switchman/call_super.rb
switchman-3.5.12 lib/switchman/call_super.rb
switchman-3.5.11 lib/switchman/call_super.rb
switchman-3.5.10 lib/switchman/call_super.rb
switchman-3.5.9 lib/switchman/call_super.rb
switchman-3.5.8 lib/switchman/call_super.rb
switchman-3.5.7 lib/switchman/call_super.rb
switchman-3.5.6 lib/switchman/call_super.rb
switchman-3.5.5 lib/switchman/call_super.rb
switchman-3.5.4 lib/switchman/call_super.rb
switchman-3.5.3 lib/switchman/call_super.rb