Module: Paramore::Validate
- Defined in:
- lib/paramore/validate.rb
Class Method Summary collapse
Class Method Details
.hash_types(hash) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/paramore/validate.rb', line 28 def hash_types(hash) hash.flat_map do |param_name, field| raise Paramore::NonField.new(param_name, field) unless field.is_a?(Paramore::Field) field.type.is_a?(Hash) ? types(field.type) : field.type end.uniq end |
.run(root_field) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/paramore/validate.rb', line 5 def run(root_field) types(root_field.type).uniq.each do |type| unless type.respond_to?(Paramore.configuration.type_method_name) raise NoMethodError, "Paramore: type `#{type}` does not respond to " + "`#{Paramore.configuration.type_method_name}`!" end end root_field end |
.types(type) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/paramore/validate.rb', line 17 def types(type) case type when Hash hash_types(type) when Array type.flat_map { |subtype| types(subtype) } else [type] end end |