struct Athena::Validator::Constraints::Callback::Value(T)

Overview

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

Defined in:

constraints/callback.cr

Constructors

Instance Method Summary

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

def self.new(value : T) #

[View source]

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

[View source]
def clone #

[View source]
def copy_with(value _value = @value) #

[View source]
def 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]
def value : T #

Macro Detail

macro method_missing(call) #

[View source]