module

Alumna

--- Solving a circular dependency --- RuleContext needs App and Service as types, but App/Service need Rule. Forward-declare them so context can compile.

Constants

VERSION = "0.9.1"

Class methods

cache(cache : Cache, ttl : Time::Span, skip_providers : Array(String) = CacheRule::DEFAULT_SKIP) : Rule
Source
cors(origins : Array(String) = ["*"], methods : Array(String) = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"] of ::String, headers : Array(String) = ["Content-Type", "Authorization", "Accept"] of ::String, credentials : Bool = false, max_age : Int32 = 86400) : Rule
Source
jwt(secret : String | Bytes, store_key : String = "jwt", header : String = "Authorization", scheme : String = "Bearer", required : Bool = true, skip_providers : Array(String) = Session::DEFAULT_SKIP, leeway : Time::Span = Time::Span.zero, iss : String | Nil = nil, aud : String | Nil = nil) : Rule
Source
logger(io : IO = STDOUT) : Rule
Source
memory(schema : Schema | Nil = nil)

Overload without a block

Source
memory(schema : Schema | Nil = nil, &)

Overload with a block

Source
rate_limit(limit : Int32 = 100, window_seconds : Int32 = 60, key : Proc(RuleContext, String) = ->(ctx : RuleContext) do ctx.remote_ip end, store : RateLimitStore | Nil = nil) : Rule

Fixed-window rate limiter. Default store is MemoryRateLimitStore. Pass store: to inject another RateLimitStore (for example Redis). window_seconds sets the memory store window when store: is omitted.

Source
timestamp(*fields : String) : Rule

Injects the current UTC timestamp into the specified fields of ctx.data. Designed to be used with explicit method scopes (e.g., on: :create or on: :write).

Source
to_any(v : Int8 | Int16 | Int32 | UInt8 | UInt16 | UInt32 | UInt64) : AnyData

DX Helper: Auto-cast common types to their AnyData equivalents

Source
to_any(v : Float32) : AnyData
Source
to_any(v : AnyData) : AnyData
Source
validate(schema : Schema) : Rule
Source

Macros

hash

Helper macro to cleanly instantiate a Hash(String, AnyData) without the of String => AnyData generic friction.

Source

Nested types