Class: Odin::Types::SchemaField

Inherits:
Object
  • Object
show all
Defined in:
lib/odin/types/schema.rb

Overview

Schema field definition

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, field_type:, required: false, nullable: false, redacted: false, deprecated: false, constraints: [], conditionals: [], default_value: nil, description: nil, computed: false, immutable: false, type_ref: nil, union_members: nil) ⇒ SchemaField

Returns a new instance of SchemaField.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/odin/types/schema.rb', line 126

def initialize(name:, field_type:, required: false, nullable: false,
               redacted: false, deprecated: false, constraints: [],
               conditionals: [], default_value: nil, description: nil,
               computed: false, immutable: false, type_ref: nil,
               union_members: nil)
  @name = name.freeze
  @field_type = field_type
  @required = required
  @nullable = nullable
  @redacted = redacted
  @deprecated = deprecated
  @constraints = constraints.freeze
  @conditionals = conditionals.freeze
  @default_value = default_value
  @description = description&.freeze
  @computed = computed
  @immutable = immutable
  @type_ref = type_ref&.freeze
  @union_members = union_members&.freeze
  freeze
end

Instance Attribute Details

#computedObject (readonly)

Returns the value of attribute computed.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def computed
  @computed
end

#conditionalsObject (readonly)

Returns the value of attribute conditionals.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def conditionals
  @conditionals
end

#constraintsObject (readonly)

Returns the value of attribute constraints.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def constraints
  @constraints
end

#default_valueObject (readonly)

Returns the value of attribute default_value.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def default_value
  @default_value
end

#deprecatedObject (readonly)

Returns the value of attribute deprecated.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def deprecated
  @deprecated
end

#descriptionObject (readonly)

Returns the value of attribute description.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def description
  @description
end

#field_typeObject (readonly)

Returns the value of attribute field_type.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def field_type
  @field_type
end

#immutableObject (readonly)

Returns the value of attribute immutable.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def immutable
  @immutable
end

#nameObject (readonly)

Returns the value of attribute name.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def name
  @name
end

#nullableObject (readonly)

Returns the value of attribute nullable.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def nullable
  @nullable
end

#redactedObject (readonly)

Returns the value of attribute redacted.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def redacted
  @redacted
end

#requiredObject (readonly)

Returns the value of attribute required.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def required
  @required
end

#type_refObject (readonly)

Returns the value of attribute type_ref.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def type_ref
  @type_ref
end

#union_membersObject (readonly)

Returns the value of attribute union_members.



122
123
124
# File 'lib/odin/types/schema.rb', line 122

def union_members
  @union_members
end

Instance Method Details

#union?Boolean

Type members for a union field (e.g. [:number, :null]); nil when not a union.

Returns:

  • (Boolean)


149
150
151
# File 'lib/odin/types/schema.rb', line 149

def union?
  !@union_members.nil?
end