Module: InterfaceComparator

Defined in:
lib/interface_comparator.rb,
lib/interface_comparator/version.rb

Overview

Module that checks if two objects has the same interface including public methods list and their arity

Constant Summary collapse

VERSION =
'0.1.1'.freeze

Class Method Summary collapse

Class Method Details

.diff_interfaces(a, b) ⇒ Object

show me the difference between interface of these two objects



12
13
14
15
16
17
18
# File 'lib/interface_comparator.rb', line 12

def self.diff_interfaces(a, b)
  methods_diff = diff_methods(a, b)
  return methods_diff unless methods_diff.empty?
  arity_diff = methods_arity_diff(a, b)
  return arity_diff unless arity_diff.empty?
  []
end

.interfaces_are_same?(a, b) ⇒ Boolean

is the interface of this two objects are the same?

Returns:

  • (Boolean)


7
8
9
# File 'lib/interface_comparator.rb', line 7

def self.interfaces_are_same?(a, b)
  diff_interfaces(a, b).empty?
end