module Interface::ClassMethods

Public Instance Methods

implement(*modules)
Alias for: implements
implements(*modules) click to toggle source
# File lib/interface.rb, line 32
def implements(*modules)
  modules.flatten.reverse!.each { |mod| include mod.extend(Abstract) }
end
Also aliased as: implement
interfaces() click to toggle source
# File lib/interface.rb, line 37
def interfaces
  klass = is_a?(Class) ? self : self.class
  klass.included_modules.select { |mod| mod.is_a?(Abstract) }
end
unimplemented_methods() click to toggle source
# File lib/interface.rb, line 42
def unimplemented_methods
  interfaces.inject({}) do |hash, interface|
    methods = unimplemented_methods_for(interface)
    methods.empty? ? hash : hash.merge!(interface => methods)
  end
end
unimplemented_methods_for(interface) click to toggle source
# File lib/interface.rb, line 49
def unimplemented_methods_for(interface)
  interface.instance_methods(false).reject do |method|
    !method_defined?(method.to_sym) || instance_method(method.to_sym).owner != interface
  end.sort.map(&:to_sym)
end