abstract class Avram::Operation

Included Modules

Defined in:

avram/operation.cr

Constant Summary

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

Constructors

Class Method Summary

Macro Summary

Instance Method Summary

Macros inherited from module Avram::Callbacks

after_commit(method_name, if _if = nil, unless _unless = nil)
after_commit(if _if = nil, unless _unless = nil, &block)
after_commit
, after_delete(method_name, if _if = nil, unless _unless = nil)
after_delete(if _if = nil, unless _unless = nil, &block)
after_delete
, after_run(method_name)
after_run(&block)
after_run
, after_save(method_name, if _if = nil, unless _unless = nil)
after_save(if _if = nil, unless _unless = nil, &block)
after_save
, before_delete(method_name, if _if = nil, unless _unless = nil)
before_delete(if _if = nil, unless _unless = nil)
before_delete
, before_run(method_name)
before_run
before_run
, before_save(method_name, if _if = nil, unless _unless = nil)
before_save(if _if = nil, unless _unless = nil)
before_save
, conditional_error_for_block_callbacks(callback, condition) conditional_error_for_block_callbacks

Macros inherited from module Avram::ParamKeyOverride

define_param_key_override define_param_key_override

Instance methods inherited from module Avram::OperationErrors

add_error(key : Symbol, message : String) : Nil add_error, errors : Hash(Symbol, Array(String)) errors

Instance methods inherited from module Avram::Validations

validate_acceptance_of(attribute : Avram::Attribute(Bool), message : Avram::Attribute::ErrorMessage = Avram.settings.i18n_backend.get(:validate_acceptance_of)) : Bool validate_acceptance_of, validate_at_most_one_filled(*attributes, message : Avram::Attribute::ErrorMessage = Avram.settings.i18n_backend.get(:validate_at_most_one_filled)) : Bool validate_at_most_one_filled, validate_confirmation_of(attribute : Avram::Attribute(T), with confirmation_attribute : Avram::Attribute(T), message : Avram::Attribute::ErrorMessage = Avram.settings.i18n_backend.get(:validate_confirmation_of)) : Bool forall T validate_confirmation_of, validate_exactly_one_filled(*attributes, message : Avram::Attribute::ErrorMessage = Avram.settings.i18n_backend.get(:validate_exactly_one_filled)) : Bool validate_exactly_one_filled, validate_format_of(attribute : Avram::Attribute(String), with regex : Regex, match : Bool = true, message : Avram::Attribute::ErrorMessage = Avram.settings.i18n_backend.get(:validate_format_of), allow_nil : Bool = false) : Bool validate_format_of, validate_inclusion_of(attribute : Avram::Attribute(T), in allowed_values : Enumerable(T), message : Avram::Attribute::ErrorMessage = Avram.settings.i18n_backend.get(:validate_inclusion_of), allow_nil : Bool = false) : Bool forall T validate_inclusion_of, validate_numeric(attribute : Avram::Attribute(Number), greater_than = nil, less_than = nil, message = nil, allow_nil : Bool = false) : Bool
validate_numeric(attribute : Avram::Attribute(Number), *, at_least = nil, no_more_than = nil, message = nil, allow_nil : Bool = false) : Bool
validate_numeric
, validate_required(*attributes, message : Avram::Attribute::ErrorMessage = Avram.settings.i18n_backend.get(:validate_required)) : Bool validate_required, validate_size_of(attribute : Avram::Attribute(String) | Avram::Attribute(Array(T)), min : Number | Nil = nil, max : Number | Nil = nil, message : Avram::Attribute::ErrorMessage | Nil = nil, allow_nil : Bool = false) : Bool forall T
validate_size_of(attribute : Avram::Attribute(String) | Avram::Attribute(Array(T)), *, is exact_size : Number, message : Avram::Attribute::ErrorMessage = Avram.settings.i18n_backend.get(:validate_exact_size_of), allow_nil : Bool = false) : Bool forall T
validate_size_of

Macros inherited from module Avram::Validations

default_validations default_validations

Instance methods inherited from module Avram::DefineAttribute

attributes attributes

Macros inherited from module Avram::DefineAttribute

attribute(type_declaration) attribute, ensure_base_attributes_method_is_present ensure_base_attributes_method_is_present, file_attribute(key) file_attribute, inherit_attributes inherit_attributes

Macros inherited from module Avram::NeedyInitializer

generate_initializer(attribute_method_args, attribute_params) generate_initializer, generate_initializers generate_initializers, inherit_needs inherit_needs, needs(type_declaration) needs

Instance methods inherited from class Object

blank_for_validates_required? : Bool blank_for_validates_required?

Constructor Detail

def self.new(params : Avram::Paramable) #

[View source]
def self.new #

[View source]

Class Method Detail

def self.param_key : String #

[View source]
def self.run(params : Avram::Paramable, *args, **named_args, &) #

Yields the instance of the operation, and the return value from the #run instance method.

MyOperation.run(params) do |operation, value|
  # operation is complete
end

[View source]
def self.run(*args, **named_args, &) #

Yields the instance of the operation, and the return value from the #run instance method.

MyOperation.run do |operation, value|
  # operation is complete
end

[View source]
def self.run!(params : Avram::Paramable, *args, **named_args) #

Returns the value from the #run instance method. or raise Avram::FailedOperation if the operation fails.

value = MyOperation.run!(params)

[View source]
def self.run!(*args, **named_args) #

Returns the value from the #run instance method. or raise Avram::FailedOperation if the operation fails.

value = MyOperation.run!

[View source]

Macro Detail

macro param_key(key) #

Instance Method Detail

def after_run(_value) #

[View source]
def before_run #

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

def params : Avram::Paramable #

[View source]
abstract def run #

[View source]
def valid? : Bool #

Returns true if all attributes are valid, and there's no custom errors


[View source]