class
AzuCLI::Generate::Model
- AzuCLI::Generate::Model
- Teeplate::FileTree
- Reference
- Object
Overview
Model generator that creates CQL::ActiveRecord::Model classes
Defined in:
azu_cli/generators/model.crConstant Summary
-
OUTPUT_DIR =
"./src/models"
Constructors
Instance Method Summary
-
#____collect_files(____files)
:nodoc:
- #__ecr0(____io)
-
#association_declarations : String
Get association declarations
- #associations : Hash(String, String)
- #associations=(associations : Hash(String, String))
- #attributes : Hash(String, String)
- #attributes=(attributes : Hash(String, String))
-
#constructor_params : String
Get constructor parameters
-
#crystal_type(attr_type : String) : String
Get Crystal type for attribute
- #database : String
- #database=(database : String)
-
#db_context_declaration : String
Get database context declaration
- #fields : Hash(String, String)
- #fields=(fields : Hash(String, String))
-
#full_model_name : String
Get the full model name with module (e.g., "Post::PostModel")
- #generate_migration : Bool
- #generate_migration=(generate_migration : Bool)
-
#getter_declarations : String
Get getter declarations (CQL ActiveRecord style)
-
#has_associations? : Bool
Check if model has associations
-
#has_scopes? : Bool
Check if model has scopes
-
#has_validations? : Bool
Check if model has validations
- #id_type : String
- #id_type=(id_type : String)
-
#include_statement : String
Get include statement (CQL ActiveRecord style)
-
#index_options(attr_type : String, field : String) : String
Get index options
-
#migration_field_options(attr_type : String, field : String) : String
Get migration field options
-
#migration_field_type(attr_type : String) : String
Get migration field type for CQL migrations
-
#model_class_name : String
Get the model class name (e.g., "PostModel")
-
#module_name : String
Get the module name from the database context
-
#name : String
Model configuration properties
-
#name=(name : String)
Model configuration properties
-
#nullable_type(attr_type : String) : String
Get nullable type representation
-
#nullable_type?(attr_type : String) : Bool
Check if type is nullable
-
#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)
-
#resource_module_name : String
Get the resource module name (for nesting the model)
- #resource_plural : String
- #resource_plural=(resource_plural : String)
-
#scope_declarations : String
Get scope declarations
- #scopes : Array(String)
- #scopes=(scopes : Array(String))
-
#should_add_index?(attr_type : String, field : String) : Bool
Check if field should have an index
-
#snake_case_name : String
Convert name to snake_case for file naming
- #snake_case_name=(snake_case_name : String)
-
#table_name : String
Convert name to plural form for table naming
- #timestamps : Bool
- #timestamps=(timestamps : Bool)
-
#validation_declarations : String
Get validation declarations (CQL ActiveRecord style)
- #validations : Hash(String, Array(String))
- #validations=(validations : Hash(String, Array(String)))
Constructor Detail
Instance Method Detail
Get migration field options
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)
Check if field should have an index