Class: Candid::Internal::Types::Model::Field
- Inherits:
-
Object
- Object
- Candid::Internal::Types::Model::Field
- Defined in:
- lib/candid/internal/types/model/field.rb
Overview
Definition of a field on a model
Instance Attribute Summary collapse
-
#api_name ⇒ Object
readonly
Returns the value of attribute api_name.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nullable ⇒ Object
readonly
Returns the value of attribute nullable.
-
#optional ⇒ Object
readonly
Returns the value of attribute optional.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name:, type:, optional: false, nullable: false, api_name: nil, value: nil, default: nil) ⇒ Field
constructor
A new instance of Field.
- #literal? ⇒ Boolean
Constructor Details
#initialize(name:, type:, optional: false, nullable: false, api_name: nil, value: nil, default: nil) ⇒ Field
Returns a new instance of Field.
11 12 13 14 15 16 17 18 19 |
# File 'lib/candid/internal/types/model/field.rb', line 11 def initialize(name:, type:, optional: false, nullable: false, api_name: nil, value: nil, default: nil) @name = name.to_sym @type = type @optional = optional @nullable = nullable @api_name = (api_name || name).to_sym @value = value @default = default end |
Instance Attribute Details
#api_name ⇒ Object (readonly)
Returns the value of attribute api_name.
9 10 11 |
# File 'lib/candid/internal/types/model/field.rb', line 9 def api_name @api_name end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
9 10 11 |
# File 'lib/candid/internal/types/model/field.rb', line 9 def default @default end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/candid/internal/types/model/field.rb', line 9 def name @name end |
#nullable ⇒ Object (readonly)
Returns the value of attribute nullable.
9 10 11 |
# File 'lib/candid/internal/types/model/field.rb', line 9 def nullable @nullable end |
#optional ⇒ Object (readonly)
Returns the value of attribute optional.
9 10 11 |
# File 'lib/candid/internal/types/model/field.rb', line 9 def optional @optional end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/candid/internal/types/model/field.rb', line 9 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/candid/internal/types/model/field.rb', line 9 def value @value end |
Instance Method Details
#literal? ⇒ Boolean
21 22 23 |
# File 'lib/candid/internal/types/model/field.rb', line 21 def literal? !value.nil? end |