Class: DbSchema::Definitions::Field::Array

Inherits:
Base
  • Object
show all
Defined in:
lib/db_schema/definitions/field/array.rb

Instance Attribute Summary

Attributes inherited from Base

#default, #name

Instance Method Summary collapse

Methods inherited from Base

attributes, #custom?, default_attribute_values, #default_is_expression?, #null?, #options, #primary_key?, register, #type, type, valid_attributes, #with_attribute, #with_type

Constructor Details

#initialize(name, **options) ⇒ Array

Returns a new instance of Array.



7
8
9
10
# File 'lib/db_schema/definitions/field/array.rb', line 7

def initialize(name, **options)
  type_class = Field.type_class_for(options[:element_type])
  super(name, **options.merge(element_type: type_class))
end

Instance Method Details

#array?Boolean

Returns:



16
17
18
# File 'lib/db_schema/definitions/field/array.rb', line 16

def array?
  true
end

#attributesObject



12
13
14
# File 'lib/db_schema/definitions/field/array.rb', line 12

def attributes
  super.merge(element_type: element_type.type)
end

#custom_element_type?Boolean

Returns:



24
25
26
# File 'lib/db_schema/definitions/field/array.rb', line 24

def custom_element_type?
  element_type.superclass == Custom
end

#element_typeObject



20
21
22
# File 'lib/db_schema/definitions/field/array.rb', line 20

def element_type
  @attributes[:element_type]
end