class

Avram::SaveOperation(T)

Inherits Avram::AddColumnAttributes < Avram::Upsert < Avram::InheritColumnAttributes < Avram::MarkAsFailed < Avram::NestedSaveOperation < Avram::DatabaseValidations < Avram::SaveCallbacks < Avram::AfterCommitCallback < Avram::CallbackHelpers < Avram::NeedyInitializerAndSaveMethods < Avram::ParamKeyOverride < Avram::OperationErrors < Avram::Validations < Avram::DefineAttribute < Reference < Object

Constants

ATTRIBUTES = [] of Nil
OPERATION_NEEDS = [] of Nil

Constructors

Class methods

param_key
Source
upsert(*args, **named_args)

Performs a create or update depending on if there is a conflicting row in the database.

See Avram::Upsert.upsert_lookup_columns for full documentation and examples.

Source
upsert!(*args, **named_args)

Performs a create or update depending on if there is a conflicting row in the database.

See Avram::Upsert.upsert_lookup_columns for full documentation and examples.

Source

Instance methods

after_commit(_record : T)
Source
after_save(_record : T)
Source
attributes
Source
before_save
Source
changes
Source
created?
Source
custom_errors
database

A helper method to backfill accessing the database before they were split in to read/write methods

Source
generic_attributes
Source
new_record?

#persisted? always returns true in after_* hooks, whether a new record was created, or an existing one was updated.

This method should always return true for a create or false for an update, independent of the stage we are at in the operation.

Source
params
Source
persisted?
Source
primary_key_name(*args, **options)
Source
primary_key_name(*args, **options, &)
Source
run_default_validations

Runs all required validations for required types as well as any additional valitaions the type needs to run e.g. polymorphic validations

Source
save
Source
save!
Source
save_failed?

Return true if the operation has run and the record failed to save

Source
save_status
Source
save_status=(save_status : OperationStatus)
Source
saved?

Returns true if the operation has run and saved the record successfully

Source
table_name(*args, **options)
Source
table_name(*args, **options, &)
Source
update!
Source
updated?
Source
valid?

Runs required validation, then returns true if all attributes are valid, and there's no custom errors

Source
write_database(*args, **options)
Source
write_database(*args, **options, &)
Source

Macros

add_cast_value_methods(columns)
Source
param_key(key)
permit_columns(*attribute_names)
Source
skip_default_validations

This allows you to skip the default validations which may be used as an escape hatch when you want to allow storing an empty string value.

Source

Nested types