class Marten::CLI::Generator::Model::FieldDefinition

Overview

Represents a model field definition.

Field definitions are specified using either of the following formats:

Where #name is the name of the field and #type is the type of the field.

#qualifier can be required depending on the considered field type; when this is the case, it corresponds to a mandatory field option. For example, label:string{128} will produce a string field whose max_size option is set to 128. Another example: author:many_to_one{User} will produce a many-to-one field whose to option is set to target the User model.

modifier is an optional field modifier. Field modifiers are used to specify additional (but non-mandatory) field options. For example: name:string:uniq will produce a string field whose unique option is set to true. Another example: name:string:uniq:index will produce a string field whose unique and index options are set to true.

Defined in:

marten/cli/generator/model/field_definition.cr
marten/cli/generator/model/field_definition/qualifier_renderer.cr

Constructors

Instance Method Summary

Constructor Detail

def self.from_argument(argument : String) : FieldDefinition #

[View source]
def self.new(name : String, type : String, qualifier : String | Nil, modifiers : Array(Modifier)) #

[View source]

Instance Method Detail


[View source]
def name : String #

[View source]
def primary_key? #

[View source]
def qualifier : String? #

[View source]
def render : String #

[View source]
def type : String #

[View source]