class Marten::DB::Field::Slug

Overview

Represents a slug field.

Included Modules

Defined in:

marten/db/field.cr
marten/db/field/slug.cr

Constructors

Macro Summary

Instance Method Summary

Instance methods inherited from module Marten::Core::Sluggable

generate_slug(value, max_size) generate_slug

Instance methods inherited from class Marten::DB::Field::String

default : String? default, empty_value?(value) : ::Bool empty_value?, from_db(value) : ::String | Nil from_db, from_db_result_set(result_set : ::DB::ResultSet) : ::String | Nil from_db_result_set, max_size : Int32 max_size, min_size : Int32? min_size, to_column : Management::Column::Base | Nil to_column, to_db(value) : ::DB::Any to_db, validate(record, value) validate

Constructor methods inherited from class Marten::DB::Field::String

new(id : ::String, max_size : Int32, min_size : Int32 | Nil = nil, primary_key = false, default : ::String | Nil = nil, blank = false, null = false, unique = false, index = false, db_column = nil) new

Instance methods inherited from class Marten::DB::Field::Base

blank? : Bool blank?, db_column db_column, db_column! : ::String db_column!, db_column? db_column?, default default, empty_value?(value) : ::Bool empty_value?, from_db(value) from_db, from_db_result_set(result_set : ::DB::ResultSet) from_db_result_set, getter_value?(value) : ::Bool getter_value?, id : String id, index? : Bool index?, null? : Bool null?, prepare_save(record, new_record = false) prepare_save, primary_key? : Bool primary_key?, related_model related_model, relation? relation?, relation_name relation_name, to_column : Management::Column::Base | Nil to_column, to_db(value) : ::DB::Any to_db, truthy_value?(value) truthy_value?, unique? : Bool unique?, validate(record, value) validate

Constructor methods inherited from class Marten::DB::Field::Base

new(id : ::String, primary_key : ::Bool = false, blank : ::Bool = false, null : ::Bool = false, unique : ::Bool = false, index : ::Bool = false, db_column : ::String | Symbol | Nil = nil) new

Constructor Detail

def self.new(id : ::String, max_size : Int32 = 50, primary_key = false, default : ::String | Nil = nil, blank = false, null = false, unique = false, index = true, db_column = nil, slugify : Symbol | Nil = nil) #

[View source]

Macro Detail

macro check_definition(field_id, kwargs) #

[View source]

Instance Method Detail

def prepare_save(record, new_record = false) #
Description copied from class Marten::DB::Field::Base

Runs pre-save logic for the specific field and record at hand.

This method does nothing by default but can be overridden for specific fields that need to set values on the model instance before save or perform any pre-save logic.


[View source]
def validate(record, value) #
Description copied from class Marten::DB::Field::Base

Runs custom validation logic for a specific model field and model object.

This method should be overriden for each field implementation that requires custom validation logic.


[View source]