Method: GraphQL::Schema::Member::HasDirectives.get_directives
- Defined in:
- lib/graphql/schema/member/has_directives.rb
.get_directives(schema_member, directives, directives_method) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/graphql/schema/member/has_directives.rb', line 50 def get_directives(schema_member, directives, directives_method) case schema_member when Class inherited_directives = if schema_member.superclass.respond_to?(directives_method) get_directives(schema_member.superclass, schema_member.superclass.public_send(directives_method), directives_method) else GraphQL::EmptyObjects::EMPTY_ARRAY end if !inherited_directives.empty? && directives dirs = [] merge_directives(dirs, inherited_directives) merge_directives(dirs, directives) dirs elsif directives directives elsif !inherited_directives.empty? inherited_directives else GraphQL::EmptyObjects::EMPTY_ARRAY end when Module dirs = nil schema_member.ancestors.reverse_each do |ancestor| if ancestor.respond_to?(:own_directives) && !(anc_dirs = ancestor.own_directives).empty? dirs ||= [] merge_directives(dirs, anc_dirs) end end if directives dirs ||= [] merge_directives(dirs, directives) end dirs || GraphQL::EmptyObjects::EMPTY_ARRAY when HasDirectives directives || GraphQL::EmptyObjects::EMPTY_ARRAY else raise "Invariant: how could #{schema_member} not be a Class, Module, or instance of HasDirectives?" end end |