class

AzuCLI::Generate::Model

Inherits Teeplate::FileTree < Reference < Object

Model generator that creates CQL::ActiveRecord::Model classes

Constants

OUTPUT_DIR = "./src/models"

Constructors

new(name : String, attributes : Hash(String, String), timestamps : Bool = true, database : String = "AppDB", id_type : String = "Int64", generate_migration : Bool = true)
Source

Instance methods

____collect_files(____files)

:nodoc:

Source
__ecr1(____io)
Source
association_declarations

Get association declarations

Source
associations
Source
associations=(associations : Hash(String, String))
Source
attributes
Source
attributes=(attributes : Hash(String, String))
Source
constructor_params

Get constructor parameters

Source
crystal_type(attr_type : String) : String

Get Crystal type for attribute

Source
database
Source
database=(database : String)
Source
db_context_declaration

Get database context declaration

Source
fields
Source
fields=(fields : Hash(String, String))
Source
full_model_name

Get the full model name with module (e.g., "Post::PostModel")

Source
generate_migration
Source
generate_migration=(generate_migration : Bool)
Source
getter_declarations

Get getter declarations (CQL ActiveRecord style)

Source
has_associations?

Check if model has associations

Source
has_scopes?

Check if model has scopes

Source
has_validations?

Check if model has validations

Source
id_type
Source
id_type=(id_type : String)
Source
include_statement

Get include statement (CQL ActiveRecord style)

Source
index_options(attr_type : String, field : String) : String

Get index options

Source
migration_field_options(attr_type : String, field : String) : String

Get migration field options

Source
migration_field_type(attr_type : String) : String

Get migration field type for CQL migrations

Source
model_class_name

Get the model class name (e.g., "PostModel")

Source
module_name

Get the module name from the database context

Source
name

Model configuration properties

Source
name=(name : String)

Model configuration properties

Source
nullable_type(attr_type : String) : String

Get nullable type representation

Source
nullable_type?(attr_type : String) : Bool

Check if type is nullable

Source
render(output_path : String, force : Bool = false, interactive : Bool = true, list : Bool = false, color : Bool = false)

In the render method or after model file generation, if generate_migration is true, generate migration (Assume migration generator is available as AzuCLI::Generate::Migration)

Source
resource_module_name

Get the resource module name (for nesting the model)

Source
resource_plural
Source
resource_plural=(resource_plural : String)
Source
scope_declarations

Get scope declarations

Source
scopes
Source
scopes=(scopes : Array(String))
Source
should_add_index?(attr_type : String, field : String) : Bool

Check if field should have an index

Source
snake_case_name

Convert name to snake_case for file naming

Source
snake_case_name=(snake_case_name : String)
Source
table_name

Convert name to plural form for table naming

Source
timestamps
Source
timestamps=(timestamps : Bool)
Source
validation_declarations

Get validation declarations (CQL ActiveRecord style)

Source
validations
Source
validations=(validations : Hash(String, Array(String)))
Source