Module: DbSchema::Definitions::Field
- Defined in:
- lib/db_schema/definitions/field.rb,
lib/db_schema/definitions/field/base.rb,
lib/db_schema/definitions/field/json.rb,
lib/db_schema/definitions/field/uuid.rb,
lib/db_schema/definitions/field/array.rb,
lib/db_schema/definitions/field/range.rb,
lib/db_schema/definitions/field/binary.rb,
lib/db_schema/definitions/field/custom.rb,
lib/db_schema/definitions/field/boolean.rb,
lib/db_schema/definitions/field/network.rb,
lib/db_schema/definitions/field/numeric.rb,
lib/db_schema/definitions/field/datetime.rb,
lib/db_schema/definitions/field/monetary.rb,
lib/db_schema/definitions/field/character.rb,
lib/db_schema/definitions/field/geometric.rb,
lib/db_schema/definitions/field/bit_string.rb,
lib/db_schema/definitions/field/text_search.rb,
lib/db_schema/definitions/field/extensions/isn.rb,
lib/db_schema/definitions/field/extensions/seg.rb,
lib/db_schema/definitions/field/extensions/cube.rb,
lib/db_schema/definitions/field/extensions/ltree.rb,
lib/db_schema/definitions/field/extensions/citext.rb,
lib/db_schema/definitions/field/extensions/hstore.rb,
lib/db_schema/definitions/field/extensions/chkpass.rb
Defined Under Namespace
Classes: Array, Base, BigInt, Bit, Boolean, Box, Bytea, Char, Chkpass, Cidr, Circle, Citext, Cube, Custom, Date, DateRange, DoublePrecision, EAN13, Hstore, ISBN, ISBN13, ISMN, ISMN13, ISSN, ISSN13, Inet, Int4Range, Int8Range, Integer, Interval, JSON, JSONB, Line, Lseg, Ltree, MacAddr, Money, NumRange, Numeric, Path, Point, Polygon, Real, Seg, SmallInt, Text, Time, Timestamp, Timestamptz, Timetz, TsQuery, TsRange, TsTzRange, TsVector, UPC, UUID, Varbit, Varchar
Class Method Summary
collapse
Class Method Details
.build(name, type, **options) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/db_schema/definitions/field.rb', line 5
def build(name, type, **options)
if registry.key?(type)
type_class_for(type).new(name, **options)
else
Custom.new(name, type_name: type, **options)
end
end
|
.registry ⇒ Object
19
20
21
|
# File 'lib/db_schema/definitions/field.rb', line 19
def registry
@registry ||= {}
end
|
.type_class_for(type) ⇒ Object
13
14
15
16
17
|
# File 'lib/db_schema/definitions/field.rb', line 13
def type_class_for(type)
registry.fetch(type) do |type|
raise ArgumentError, "#{type.inspect} type is not supported."
end
end
|