Class: GraphqlConnector::ServiceClassable::ClassMethodValidator
- Inherits:
-
Object
- Object
- GraphqlConnector::ServiceClassable::ClassMethodValidator
- Defined in:
- lib/graphql_connector/service_classable/class_method_validator.rb
Overview
Checks whether a class method for a specific graphql query is in an expected format
Class Method Summary collapse
- .validate_class_method(class_method_name, invoked_class) ⇒ Object
- .validate_element_class_type(element, class_types) ⇒ Object
Class Method Details
.validate_class_method(class_method_name, invoked_class) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/graphql_connector/service_classable/class_method_validator.rb', line 11 def validate_class_method(class_method_name, invoked_class) return unless invoked_class.singleton_methods .map(&:to_s) .include?(class_method_name.to_s) error_msg = "The method '#{class_method_name}: ... ' is "\ 'already implemented within the context of '\ "#{invoked_class} and therefore cannot be used again!" raise ClassMethodAlreadyImplementedError, error_msg end |
.validate_element_class_type(element, class_types) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/graphql_connector/service_classable/class_method_validator.rb', line 22 def validate_element_class_type(element, class_types) return if element.class == class_types raise InvalidClassTypeError, "Please ensure that #{element} is a"\ "#{class_types}!" end |