module

CanCan::ControllerAdditions

The controller seam. Fake controllers (oracle spec) include it directly; ActionController::Base includes it with params bridged.

Instance methods

authorize!(action : Symbol, subject : Subject, message : String | Nil = nil) : Subject
authorize!(action : Symbol, *, parent : ActiveRecord::Base, child : Subject, message : String | Nil = nil) : Nil

Nested subject authorize (the gem's {parent => child} subject).

can?(action : Symbol, subject : Subject) : Bool
cancan_action

The current action as a Symbol. Crystal has no runtime String#to_sym; ActionController subclasses get a generated dispatch (macro finished below); other controllers define this themselves.

cancan_authorized?
cancan_collection(name : String) : Array(ActiveRecord::Base) | Nil
cancan_collection_defined?(name : String) : Bool
cancan_fetch_parent(name : String) : ActiveRecord::Base | Nil

A through: parent (gem: ivar or controller method). Controllers override to expose parent-fetching methods; the default reads the instance store.

cancan_instance(name : String) : ActiveRecord::Base | Nil
cancan_instance_defined?(name : String) : Bool
cancan_param(key : String) : ParamValue | Nil
cancan_permitted_params(name : String, action : String) : ParamHash | Nil

Strong parameters seam: sanitizing controllers override (the gem resolves <action>_params / <name>_params with respond_to?). Return nil to fall back to the raw resource params.

cancan_set_collection(name : String, value : Array(ActiveRecord::Base)) : Nil
cancan_set_instance(name : String, value : ActiveRecord::Base | Nil) : Nil
cancan_set_params(params : Hash) : Nil

Fake/test controllers: plain hash params. ActionController::Base bridges to its own params instead (cancan_param override).

cancan_skip(behavior : String, name : Symbol | Nil = nil, only : Array(Symbol) | Nil = nil, except : Array(Symbol) | Nil = nil) : Nil
cancan_skip_options(behavior : String, name : Symbol | Nil) : SkipOptions | Nil
cannot?(action : Symbol, subject : Subject) : Bool
current_ability