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.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/graphql/client/schema/object_type.rb', line 48 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.
30 31 32 |
# File 'lib/graphql/client/schema/object_type.rb', line 30 def defined_fields @defined_fields end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
30 31 32 |
# File 'lib/graphql/client/schema/object_type.rb', line 30 def definition @definition end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
30 31 32 |
# File 'lib/graphql/client/schema/object_type.rb', line 30 def klass @klass end |
Instance Method Details
#fields ⇒ Object
36 37 38 |
# File 'lib/graphql/client/schema/object_type.rb', line 36 def fields @klass.fields end |
#new(data = {}, errors = Errors.new) ⇒ Object
63 64 65 |
# File 'lib/graphql/client/schema/object_type.rb', line 63 def new(data = {}, errors = Errors.new) @klass.new(data, errors, self) end |
#spreads ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/graphql/client/schema/object_type.rb', line 40 def spreads if defined?(@spreads) @spreads else EMPTY_SET end end |
#type ⇒ Object
32 33 34 |
# File 'lib/graphql/client/schema/object_type.rb', line 32 def type @klass.type end |