Skip to content

struct Athena::Validator::Constraints::Callback::Value(T)
inherits Athena::Validator::Constraints::Callback::ValueContainer #

Wrapper type to allow passing arbitrarily typed values as arguments in the AVD::Constraints::Callback::CallbackProc.

Constructors#

.new(value : T)#

View source

Methods#

#==(other) : Bool#

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
View source

#clone#

View source

#copy_with(value _value = @value)#

View source

#get(as _t : T.class) : T forall T#

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

View source

#value : T#

Macros#

method_missing(call)#

View source