class AzuCLI::Generate::Model

Overview

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

Defined in:

azu_cli/generators/model.cr

Constant Summary

OUTPUT_DIR = "./src/models"

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String, attributes : Hash(String, String), timestamps : Bool = true, database : String = "AppSchema", id_type : String = "UUID", generate_migration : Bool = true) #

[View source]

Instance Method Detail

def ____collect_files(____files) #
Description copied from class Teeplate::FileTree

:nodoc:


[View source]
def __ecr0(____io) #

[View source]
def association_declarations : String #

Get association declarations


[View source]
def associations : Hash(String, String) #

[View source]
def associations=(associations : Hash(String, String)) #

[View source]
def attributes : Hash(String, String) #

[View source]
def attributes=(attributes : Hash(String, String)) #

[View source]
def constructor_params : String #

Get constructor parameters


[View source]
def crystal_type(attr_type : String) : String #

Get Crystal type for attribute


[View source]
def database : String #

[View source]
def database=(database : String) #

[View source]
def db_context_declaration : String #

Get database context declaration


[View source]
def fields : Hash(String, String) #

[View source]
def fields=(fields : Hash(String, String)) #

[View source]
def full_model_name : String #

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


[View source]
def generate_migration : Bool #

[View source]
def generate_migration=(generate_migration : Bool) #

[View source]
def getter_declarations : String #

Get getter declarations (CQL ActiveRecord style)


[View source]
def has_associations? : Bool #

Check if model has associations


[View source]
def has_scopes? : Bool #

Check if model has scopes


[View source]
def has_validations? : Bool #

Check if model has validations


[View source]
def id_type : String #

[View source]
def id_type=(id_type : String) #

[View source]
def include_statement : String #

Get include statement (CQL ActiveRecord style)


[View source]
def index_options(attr_type : String, field : String) : String #

Get index options


[View source]
def migration_field_options(attr_type : String, field : String) : String #

Get migration field options


[View source]
def migration_field_type(attr_type : String) : String #

Get migration field type for CQL migrations


[View source]
def model_class_name : String #

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


[View source]
def module_name : String #

Get the module name from the database context


[View source]
def name : String #

Model configuration properties


[View source]
def name=(name : String) #

Model configuration properties


[View source]
def nullable_type(attr_type : String) : String #

Get nullable type representation


[View source]
def nullable_type?(attr_type : String) : Bool #

Check if type is nullable


[View source]
def 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)


[View source]
def resource_module_name : String #

Get the resource module name (for nesting the model)


[View source]
def resource_plural : String #

[View source]
def resource_plural=(resource_plural : String) #

[View source]
def scope_declarations : String #

Get scope declarations


[View source]
def scopes : Array(String) #

[View source]
def scopes=(scopes : Array(String)) #

[View source]
def should_add_index?(attr_type : String, field : String) : Bool #

Check if field should have an index


[View source]
def snake_case_name : String #

Convert name to snake_case for file naming


[View source]
def snake_case_name=(snake_case_name : String) #

[View source]
def table_name : String #

Convert name to plural form for table naming


[View source]
def timestamps : Bool #

[View source]
def timestamps=(timestamps : Bool) #

[View source]
def validation_declarations : String #

Get validation declarations (CQL ActiveRecord style)


[View source]
def validations : Hash(String, Array(String)) #

[View source]
def validations=(validations : Hash(String, Array(String))) #

[View source]