module ServiceActor::TypeCheckable::PrependedMethods
Public Instance Methods
_call()
click to toggle source
Calls superclass method
# File lib/service_actor/type_checkable.rb, line 20 def _call check_type_definitions(self.class.inputs, kind: 'Input') super check_type_definitions(self.class.outputs, kind: 'Output') end
Private Instance Methods
check_type_definitions(definitions, kind:)
click to toggle source
# File lib/service_actor/type_checkable.rb, line 30 def check_type_definitions(definitions, kind:) definitions.each do |key, options| type_definition = options[:type] || next value = result[key] || next types = types_for_definition(type_definition) next if types.any? { |type| value.is_a?(type) } raise ArgumentError, "#{kind} #{key} on #{self.class} must be of type " \ "#{types.join(', ')} but was #{value.class}" end end
types_for_definition(type_definition)
click to toggle source
# File lib/service_actor/type_checkable.rb, line 44 def types_for_definition(type_definition) Array(type_definition).map do |name| name.is_a?(String) ? Object.const_get(name) : name end end