abstract class Avram::SaveOperation(T)

Included Modules

Defined in:

avram/save_operation.cr

Constant Summary

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

Constructors

Class Method Summary

Instance Method Summary

Macro Summary

Instance methods inherited from module Avram::MarkAsFailed

mark_as_failed mark_as_failed

Instance methods inherited from module Avram::NestedSaveOperation

mark_nested_save_operations_as_failed mark_nested_save_operations_as_failed, nested_save_operations nested_save_operations

Instance methods inherited from class Avram::Operation

params : Avram::Paramable params, valid? valid?

Constructor methods inherited from class Avram::Operation

new(params : Avram::Paramable)
new
new

Class methods inherited from class Avram::Operation

param_key param_key

Instance methods inherited from module Avram::SaveOperationErrors

errors : Hash(Symbol, Array(String)) errors

Instance methods inherited from module Avram::Validations

validate_acceptance_of(attribute : Avram::Attribute(Bool | Nil), message : Avram::Attribute::ErrorMessage = "must be accepted") validate_acceptance_of, validate_at_most_one_filled(*attributes, message : Avram::Attribute::ErrorMessage = "must be blank") validate_at_most_one_filled, validate_confirmation_of(attribute : Avram::Attribute(T), with confirmation_attribute : Avram::Attribute(T), message : Avram::Attribute::ErrorMessage = "must match") forall T validate_confirmation_of, validate_exactly_one_filled(*attributes, message : Avram::Attribute::ErrorMessage = "at least one must be filled") validate_exactly_one_filled, validate_inclusion_of(attribute : Avram::Attribute(T), in allowed_values : Enumerable(T), message : Avram::Attribute::ErrorMessage = "is invalid", allow_nil : Bool = false) forall T validate_inclusion_of, validate_required(*attributes, message : Avram::Attribute::ErrorMessage = "is required") validate_required, validate_size_of(attribute : Avram::Attribute, min = nil, max = nil, allow_nil : Bool = false)
validate_size_of(attribute : Avram::Attribute, *, is exact_size, message : Avram::Attribute::ErrorMessage = "is invalid", allow_nil : Bool = false)
validate_size_of
, validate_uniqueness_of(attribute : Avram::Attribute, query : Avram::Criteria, message : String = "is already taken")
validate_uniqueness_of(attribute : Avram::Attribute, message : Avram::Attribute::ErrorMessage = "is already taken")
validate_uniqueness_of

Instance methods inherited from module Avram::DefineAttribute

attributes attributes

Instance methods inherited from class Object

blank_for_validates_required? : Bool blank_for_validates_required?

Constructor Detail

def self.new(params) #

[View source]
def self.new #

[View source]

Class Method Detail

def self.param_key #

[View source]

Instance Method Detail

def after_commit(_record : T) #

[View source]
def after_save(_record : T) #

[View source]
abstract def attributes #

[View source]
def before_save #

[View source]
def changes : Hash(Symbol, String | Nil) #

[View source]
abstract def database #

[View source]
def params #

[View source]
def persisted? : Bool #

[View source]
abstract def primary_key_name #

[View source]
def record #

[View source]
def save : Bool #

[View source]
def save! : T #

[View source]
def save_failed? #

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


[View source]
def save_status #

[View source]
def save_status=(save_status : Avram::SaveOperation::SaveStatus) #

[View source]
def saved? #

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


[View source]
abstract def table_name #

[View source]
def update! : T #

[View source]
def valid? : Bool #

Runs #before_save steps, required validation, then returns true if all attributes are valid.


[View source]

Macro Detail

macro add_cast_value_methods(columns) #

[View source]
macro param_key(key) #

macro permit_columns(*attribute_names) #

[View source]