Class: GraphQL::Union
- Inherits:
-
Object
- Object
- GraphQL::Union
- Includes:
- NonNullWithBang
- Defined in:
- lib/graph_ql/union.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#possible_types ⇒ Object
readonly
Returns the value of attribute possible_types.
Instance Method Summary collapse
-
#initialize(name, desc, types) ⇒ Union
constructor
A new instance of Union.
- #kind ⇒ Object
-
#resolve_type(object) ⇒ Object
Find a type in this union for a given object.
- #to_s ⇒ Object
Methods included from NonNullWithBang
Constructor Details
#initialize(name, desc, types) ⇒ Union
Returns a new instance of Union.
4 5 6 7 8 |
# File 'lib/graph_ql/union.rb', line 4 def initialize(name, desc, types) @name = name @description = desc @possible_types = types end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/graph_ql/union.rb', line 3 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/graph_ql/union.rb', line 3 def name @name end |
#possible_types ⇒ Object (readonly)
Returns the value of attribute possible_types.
3 4 5 |
# File 'lib/graph_ql/union.rb', line 3 def possible_types @possible_types end |
Instance Method Details
#kind ⇒ Object
10 11 12 |
# File 'lib/graph_ql/union.rb', line 10 def kind GraphQL::TypeKinds::UNION end |
#resolve_type(object) ⇒ Object
Find a type in this union for a given object. Reimplement if needed
16 17 18 19 |
# File 'lib/graph_ql/union.rb', line 16 def resolve_type(object) type_name = object.class.name possible_types.find {|t| t.name == type_name} end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/graph_ql/union.rb', line 21 def to_s "<GraphQL::Union #{name}>" end |