Class: SchemaExtractor::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/schema_extractor/field.rb

Defined Under Namespace

Classes: InvalidFieldNameError, InvalidFieldTypeError, InvalidNullableValueError

Constant Summary collapse

TYPES =
i[
  boolean
  date
  datetime
  decimal
  float
  integer
  string
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, nullable:, default: nil) ⇒ Field

Returns a new instance of Field.



23
24
25
26
27
28
# File 'lib/schema_extractor/field.rb', line 23

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

#defaultObject (readonly)

Returns the value of attribute default.



21
22
23
# File 'lib/schema_extractor/field.rb', line 21

def default
  @default
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/schema_extractor/field.rb', line 18

def name
  @name
end

#nullableObject (readonly)

Returns the value of attribute nullable.



20
21
22
# File 'lib/schema_extractor/field.rb', line 20

def nullable
  @nullable
end

#typeObject (readonly)

Returns the value of attribute type.



19
20
21
# File 'lib/schema_extractor/field.rb', line 19

def type
  @type
end

Instance Method Details

#nullable?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/schema_extractor/field.rb', line 30

def nullable?
  nullable
end