Class: Odin::Types::SchemaField
- Inherits:
-
Object
- Object
- Odin::Types::SchemaField
- Defined in:
- lib/odin/types/schema.rb
Overview
Schema field definition
Instance Attribute Summary collapse
-
#computed ⇒ Object
readonly
Returns the value of attribute computed.
-
#conditionals ⇒ Object
readonly
Returns the value of attribute conditionals.
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#default_value ⇒ Object
readonly
Returns the value of attribute default_value.
-
#deprecated ⇒ Object
readonly
Returns the value of attribute deprecated.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#field_type ⇒ Object
readonly
Returns the value of attribute field_type.
-
#immutable ⇒ Object
readonly
Returns the value of attribute immutable.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nullable ⇒ Object
readonly
Returns the value of attribute nullable.
-
#redacted ⇒ Object
readonly
Returns the value of attribute redacted.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#type_ref ⇒ Object
readonly
Returns the value of attribute type_ref.
-
#union_members ⇒ Object
readonly
Returns the value of attribute union_members.
Instance Method Summary collapse
-
#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
constructor
A new instance of SchemaField.
-
#union? ⇒ Boolean
Type members for a union field (e.g. [:number, :null]); nil when not a union.
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
#computed ⇒ Object (readonly)
Returns the value of attribute computed.
122 123 124 |
# File 'lib/odin/types/schema.rb', line 122 def computed @computed end |
#conditionals ⇒ Object (readonly)
Returns the value of attribute conditionals.
122 123 124 |
# File 'lib/odin/types/schema.rb', line 122 def conditionals @conditionals end |
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
122 123 124 |
# File 'lib/odin/types/schema.rb', line 122 def constraints @constraints end |
#default_value ⇒ Object (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 |
#deprecated ⇒ Object (readonly)
Returns the value of attribute deprecated.
122 123 124 |
# File 'lib/odin/types/schema.rb', line 122 def deprecated @deprecated end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
122 123 124 |
# File 'lib/odin/types/schema.rb', line 122 def description @description end |
#field_type ⇒ Object (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 |
#immutable ⇒ Object (readonly)
Returns the value of attribute immutable.
122 123 124 |
# File 'lib/odin/types/schema.rb', line 122 def immutable @immutable end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
122 123 124 |
# File 'lib/odin/types/schema.rb', line 122 def name @name end |
#nullable ⇒ Object (readonly)
Returns the value of attribute nullable.
122 123 124 |
# File 'lib/odin/types/schema.rb', line 122 def nullable @nullable end |
#redacted ⇒ Object (readonly)
Returns the value of attribute redacted.
122 123 124 |
# File 'lib/odin/types/schema.rb', line 122 def redacted @redacted end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
122 123 124 |
# File 'lib/odin/types/schema.rb', line 122 def required @required end |
#type_ref ⇒ Object (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_members ⇒ Object (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.
149 150 151 |
# File 'lib/odin/types/schema.rb', line 149 def union? !@union_members.nil? end |