class Avram::Attribute(T)

Direct Known Subclasses

Defined in:

avram/attribute.cr

Constructors

Macro Summary

Instance Method Summary

Instance methods inherited from class Object

blank_for_validates_required? : Bool blank_for_validates_required?

Constructor Detail

def self.new(name : Symbol, value : T | Nil, param_key : String, param : Array(String) | Avram::Uploadable | String | Nil = nil) #

[View source]

Macro Detail

macro call_value_instead_error_message(method) #

[View source]

Instance Method Detail

def [](key) #

[View source]
def []?(key) #

[View source]
def add_error(message : String = "is invalid") #

[View source]
def add_error(message : Proc | Avram::CallableErrorMessage) #

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

This can be used as an escape hatch when you may have a blank string that's allowed to be saved.


[View source]
def allow_blank? : Bool #

This can be used as an escape hatch when you may have a blank string that's allowed to be saved.


[View source]
def changed?(from : T | Nil | Nothing = Nothing.new, to : T | Nil | Nothing = Nothing.new) : Bool #

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

[View source]
def extract(params : Avram::Paramable) #

[View source]
def name : Symbol #

[View source]
def original_value : T | Nil #

[View source]

[View source]
def param_key : String #

[View source]
def permitted #

[View source]
def reset_errors #

[View source]
def to_f #

[View source]
def to_f64 #

[View source]
def to_i #

[View source]
def to_i32 #

[View source]
def to_i64 #

[View source]
def to_s(time_format : String) #

NOTE to_s(io : IO) is used when passing an object in to string interpolation. Don't override that method.


[View source]
def to_s #

These methods may accidentally get called on attributes inside of operations. Since these methods don't exist, chances are, you meant to call them on the value.

username.to_s
# VS
username.value.to_s

[View source]
def valid? : Bool #

[View source]
def value : T | Nil #

[View source]
def value=(value : T | Nil) #

[View source]