Sha256: e3e0450ca1e5f6f741e64cd630db5b3fc46ba2ce5b116b88d9cdc09c3420d22b

Contents?: true

Size: 778 Bytes

Versions: 5

Compression:

Stored size: 778 Bytes

Contents

module Kernel
  private

  # Defines a method signature for a method on this object:
  #
  #   sig [:to_i, :to_i], Integer,
  #   def sum(a, b)
  #     a.to_i + b.to_i
  #   end
  #
  def sig(expected_arguments, expected_result = nil, method_name)
    if is_a?(Module)
      Sig.define(self, expected_arguments, expected_result, method_name)
    else
      sig_self(expected_arguments, expected_result, method_name)
    end
  end

  # Defines a method signature for a method on this object's singleton class
  #
  #   sig_self [:to_i, :to_i], Integer,
  #   def self.sum(a, b)
  #     a.to_i + b.to_i
  #   end
  #
  def sig_self(expected_arguments, expected_result = nil, method_name)
    Sig.define(singleton_class, expected_arguments, expected_result, method_name)
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
sig-1.0.2 lib/sig/kernel.rb
charyf_sig-1.1.2 lib/charyf_sig/kernel.rb
charyf_sig-1.1.0 lib/sig/kernel.rb
sig-1.0.1 lib/sig/kernel.rb
sig-1.0.0 lib/sig/kernel.rb