module Injected::ImplementationDsl

Attributes

implemented_interface[R]

Public Instance Methods

implements(interface) click to toggle source
# File lib/injected/implementation_dsl.rb, line 5
def implements(interface)
  @implemented_interface = interface
end

Private Instance Methods

interface_method(method_name) click to toggle source
# File lib/injected/implementation_dsl.rb, line 23
def interface_method(method_name)
  implemented_interface.interface_methods[method_name]
end
invalid_arity?(method_name) click to toggle source
# File lib/injected/implementation_dsl.rb, line 27
def invalid_arity?(method_name)
  if interface_method(method_name)
    fixed = instance_method(method_name).parameters.map do |type, arg|
      [type == :keyreq ? :key : type, arg]
    end
    interface_method(method_name).parameters != fixed
  else
    false
  end
end
method_added(method_name) click to toggle source
Calls superclass method
# File lib/injected/implementation_dsl.rb, line 13
def method_added(method_name)
  super

  return unless invalid_arity?(method_name)

  raise ArgumentError, "Invalid arity for implemented method #{method_name} for #{self}. " \
                       "Expected #{interface_method(method_name).parameters}, " \
                       "got #{instance_method(method_name).parameters}"
end