Class: SchemaExtractor::Field
- Inherits:
-
Object
- Object
- SchemaExtractor::Field
- Defined in:
- lib/schema_extractor/field.rb
Defined Under Namespace
Classes: InvalidFieldNameError, InvalidFieldTypeError, InvalidNullableValueError
Constant Summary collapse
- TYPES =
i[ date datetime decimal float integer string ].freeze
Instance Attribute Summary collapse
-
#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.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name:, type:, nullable:, default: nil) ⇒ Field
constructor
A new instance of Field.
- #nullable? ⇒ Boolean
Constructor Details
#initialize(name:, type:, nullable:, default: nil) ⇒ Field
Returns a new instance of Field.
22 23 24 25 26 27 |
# File 'lib/schema_extractor/field.rb', line 22 def initialize(name:, type:, nullable:, default: nil) @name = validate_name!(name) @type = validate_type!(type) @nullable = validate_nullable!(nullable) @default = validate_default!(default) end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
20 21 22 |
# File 'lib/schema_extractor/field.rb', line 20 def default @default end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/schema_extractor/field.rb', line 17 def name @name end |
#nullable ⇒ Object (readonly)
Returns the value of attribute nullable.
19 20 21 |
# File 'lib/schema_extractor/field.rb', line 19 def nullable @nullable end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
18 19 20 |
# File 'lib/schema_extractor/field.rb', line 18 def type @type end |
Instance Method Details
#nullable? ⇒ Boolean
29 30 31 |
# File 'lib/schema_extractor/field.rb', line 29 def nullable? nullable end |