Class: GraphQL::Client::Schema::ObjectType::WithDefinition
- Inherits:
-
Object
- Object
- GraphQL::Client::Schema::ObjectType::WithDefinition
- Includes:
- BaseType, GraphQL::Client::Schema::ObjectType
- Defined in:
- lib/graphql/client/schema/object_type.rb
Constant Summary collapse
- EMPTY_SET =
Set.new.freeze
Instance Attribute Summary collapse
-
#defined_fields ⇒ Object
readonly
Returns the value of attribute defined_fields.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Attributes included from BaseType
Instance Method Summary collapse
- #fields ⇒ Object
-
#initialize(klass, defined_fields, definition, spreads) ⇒ WithDefinition
constructor
A new instance of WithDefinition.
- #new(data = {}, errors = Errors.new) ⇒ Object
- #spreads ⇒ Object
- #type ⇒ Object
Methods included from GraphQL::Client::Schema::ObjectType
#cast, #define_class, #define_field, new
Methods included from BaseType
#cast, #to_list_type, #to_non_null_type
Constructor Details
#initialize(klass, defined_fields, definition, spreads) ⇒ WithDefinition
Returns a new instance of WithDefinition.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/graphql/client/schema/object_type.rb', line 49 def initialize(klass, defined_fields, definition, spreads) @klass = klass @defined_fields = defined_fields.map do |k, v| [-k.to_s, v] end.to_h @definition = definition @spreads = spreads unless spreads.empty? @defined_fields.keys.each do |attr| name = ActiveSupport::Inflector.underscore(attr) @klass::READERS[:"#{name}"] ||= attr @klass::PREDICATES[:"#{name}?"] ||= attr end end |
Instance Attribute Details
#defined_fields ⇒ Object (readonly)
Returns the value of attribute defined_fields.
31 32 33 |
# File 'lib/graphql/client/schema/object_type.rb', line 31 def defined_fields @defined_fields end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
31 32 33 |
# File 'lib/graphql/client/schema/object_type.rb', line 31 def definition @definition end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
31 32 33 |
# File 'lib/graphql/client/schema/object_type.rb', line 31 def klass @klass end |
Instance Method Details
#fields ⇒ Object
37 38 39 |
# File 'lib/graphql/client/schema/object_type.rb', line 37 def fields @klass.fields end |
#new(data = {}, errors = Errors.new) ⇒ Object
64 65 66 |
# File 'lib/graphql/client/schema/object_type.rb', line 64 def new(data = {}, errors = Errors.new) @klass.new(data, errors, self) end |
#spreads ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/graphql/client/schema/object_type.rb', line 41 def spreads if defined?(@spreads) @spreads else EMPTY_SET end end |
#type ⇒ Object
33 34 35 |
# File 'lib/graphql/client/schema/object_type.rb', line 33 def type @klass.type end |