struct Athena::Validator::Constraints::Callback::Value(T)
- Athena::Validator::Constraints::Callback::Value(T)
- Athena::Validator::Constraints::Callback::ValueContainer
- Struct
- Value
- Object
Overview
Wrapper type to allow passing arbitrarily typed values as arguments in the AVD::Constraints::Callback::CallbackProc
.
Defined in:
constraints/callback.crConstructors
Instance Method Summary
-
#==(other) : Bool
Returns
true
if this struct is equal to other. - #clone
- #copy_with(value _value = @value)
-
#get(as _t : T.class) : T forall T
Returns the value as
T
. - #value : T
Macro Summary
Instance methods inherited from struct Athena::Validator::Constraints::Callback::ValueContainer
initialize
initialize
Constructor methods inherited from struct Athena::Validator::Constraints::Callback::ValueContainer
new
new
Constructor Detail
Instance Method Detail
def ==(other) : Bool
#
Description copied from struct Struct
Returns true
if this struct is equal to other.
Both structs' instance vars are compared to each other. Thus, two structs are considered equal if each of their instance variables are equal. Subclasses should override this method to provide specific equality semantics.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p2 = Point.new 1, 2
p3 = Point.new 3, 4
p1 == p2 # => true
p1 == p3 # => false
Returns the value as T
.
If used inside a AVD::Constraints::Callback@class-method
.
# Get the wrapped value as the type of the current class.
object = value.get self
If used inside a AVD::Constraints::Callback@procsblocks
.
# Get the wrapped value as the expected type.
value = value.get Int32
# Alternatively, can use normal Crystal semantics for narrowing the type.
value = value.value
case value
when Int32 then "value is Int32"
when String then "value is String"
end