Class: ArSerializer::GraphQL::SerializableTypeClass
- Inherits:
-
TypeClass
- Object
- TypeClass
- ArSerializer::GraphQL::SerializableTypeClass
show all
- Defined in:
- lib/ar_serializer/graphql/types.rb
Instance Attribute Summary
Attributes inherited from TypeClass
#except, #only, #type
Instance Method Summary
collapse
Methods inherited from TypeClass
#description, from, #initialize, #of_type, #sample, #validate!
Instance Method Details
#==(t) ⇒ Object
331
332
333
|
# File 'lib/ar_serializer/graphql/types.rb', line 331
def == t
eql? t
end
|
#association_type ⇒ Object
315
316
317
|
# File 'lib/ar_serializer/graphql/types.rb', line 315
def association_type
self
end
|
#collect_types(types) ⇒ Object
309
310
311
312
313
|
# File 'lib/ar_serializer/graphql/types.rb', line 309
def collect_types(types)
return if types[self]
types[self] = true
fields.each { |field| field.collect_types types }
end
|
#compare_elements ⇒ Object
335
336
337
|
# File 'lib/ar_serializer/graphql/types.rb', line 335
def compare_elements
[type, field_only, field_except]
end
|
#eql?(t) ⇒ Boolean
327
328
329
|
# File 'lib/ar_serializer/graphql/types.rb', line 327
def eql?(t)
self.class == t.class && self.compare_elements == t.compare_elements
end
|
#field_except ⇒ Object
280
281
282
|
# File 'lib/ar_serializer/graphql/types.rb', line 280
def field_except
[*except].map(&:to_s)
end
|
#field_only ⇒ Object
276
277
278
|
# File 'lib/ar_serializer/graphql/types.rb', line 276
def field_only
[*only].map(&:to_s)
end
|
#fields ⇒ Object
301
302
303
304
305
306
307
|
# File 'lib/ar_serializer/graphql/types.rb', line 301
def fields
keys = type._serializer_field_keys - ['__schema'] - field_except
keys = field_only & keys unless field_only.empty?
keys.map do |name|
FieldClass.new name, type._serializer_field_info(name)
end
end
|
#gql_type ⇒ Object
319
320
321
|
# File 'lib/ar_serializer/graphql/types.rb', line 319
def gql_type
name
end
|
#hash ⇒ Object
339
340
341
|
# File 'lib/ar_serializer/graphql/types.rb', line 339
def hash
compare_elements.hash
end
|
#kind ⇒ Object
284
285
286
|
# File 'lib/ar_serializer/graphql/types.rb', line 284
def kind
'OBJECT'
end
|
#name ⇒ Object
288
289
290
291
292
293
294
295
296
297
298
299
|
# File 'lib/ar_serializer/graphql/types.rb', line 288
def name
name_segments = [type.name.delete(':')]
unless field_only.empty?
name_segments << 'Only'
name_segments << field_only.map(&:camelize)
end
unless field_except.empty?
name_segments << 'Except'
name_segments << field_except.map(&:camelize)
end
name_segments.join
end
|
#ts_type ⇒ Object
323
324
325
|
# File 'lib/ar_serializer/graphql/types.rb', line 323
def ts_type
"Type#{name}"
end
|