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
341
342
343
|
# File 'lib/ar_serializer/graphql/types.rb', line 341
def == t
eql? t
end
|
#association_type ⇒ Object
325
326
327
|
# File 'lib/ar_serializer/graphql/types.rb', line 325
def association_type
self
end
|
#collect_types(types) ⇒ Object
319
320
321
322
323
|
# File 'lib/ar_serializer/graphql/types.rb', line 319
def collect_types(types)
return if types[self]
types[self] = true
fields.each { |field| field.collect_types types }
end
|
#compare_elements ⇒ Object
345
346
347
|
# File 'lib/ar_serializer/graphql/types.rb', line 345
def compare_elements
[type, field_only, field_except]
end
|
#eql?(t) ⇒ Boolean
337
338
339
|
# File 'lib/ar_serializer/graphql/types.rb', line 337
def eql?(t)
self.class == t.class && self.compare_elements == t.compare_elements
end
|
#field_except ⇒ Object
290
291
292
|
# File 'lib/ar_serializer/graphql/types.rb', line 290
def field_except
[*except].map(&:to_s)
end
|
#field_only ⇒ Object
286
287
288
|
# File 'lib/ar_serializer/graphql/types.rb', line 286
def field_only
[*only].map(&:to_s)
end
|
#fields ⇒ Object
311
312
313
314
315
316
317
|
# File 'lib/ar_serializer/graphql/types.rb', line 311
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
329
330
331
|
# File 'lib/ar_serializer/graphql/types.rb', line 329
def gql_type
name
end
|
#hash ⇒ Object
349
350
351
|
# File 'lib/ar_serializer/graphql/types.rb', line 349
def hash
compare_elements.hash
end
|
#kind ⇒ Object
294
295
296
|
# File 'lib/ar_serializer/graphql/types.rb', line 294
def kind
'OBJECT'
end
|
#name ⇒ Object
298
299
300
301
302
303
304
305
306
307
308
309
|
# File 'lib/ar_serializer/graphql/types.rb', line 298
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
333
334
335
|
# File 'lib/ar_serializer/graphql/types.rb', line 333
def ts_type
"Type#{name}"
end
|