module

CanCan::Ability

Instance methods

alias_action(*args : Symbol, to : Symbol) : Array(Symbol)

--- actions ---

aliased_actions
attributes_for(action : Symbol, subject : Subject) : Hash(String, CondVal)
authorize!(action : Symbol, subject : Subject, message : String | Nil = nil) : Subject
can(action : Symbol, subject : Subject, conditions : Hash) : Nil
can(action : Symbol, subject : Subject, raw_sql : String) : Nil
can(action : Symbol, subject : Subject, scope : ActiveRecord::Relation) : Nil
can(action : Symbol, subject : Subject, attributes : Array(Symbol), conditions : Hash | Nil = nil) : Nil
can(action : Symbol, subject : Subject, attribute : Symbol) : Nil
can(action : Symbol | Nil = nil, subject : Subject | Nil = nil) : Nil
can(actions : Array(Symbol), subject : Subject | Array(Subject)) : Nil
can(action : Symbol, subjects : Array(Subject)) : Nil
can(action : Symbol, subject : Subject, &block : Proc(BlockSubject, Symbol | Nil, Bool)) : Nil

Block also receiving the checked attribute (gem's two-argument block).

can
can?(action : Symbol, subject : Subject, attribute : Symbol | Nil = nil) : Bool
can?(action : Symbol, *, any : Array(Subject), attribute : Symbol | Nil = nil) : Bool

{any: [subjects]} — true if any subject has a matching rule (the first matched rule wins, can or cannot).

can?(action : Symbol, *, parent : ActiveRecord::Base, child : Subject, attribute : Symbol | Nil = nil) : Bool

Nested subject (the gem's {parent => child} hash): conditions involving the parent association are checked against the parent.

cannot(action : Symbol, subject : Subject, conditions : Hash) : Nil
cannot(action : Symbol, subject : Subject, raw_sql : String) : Nil
cannot(action : Symbol, subject : Subject, scope : ActiveRecord::Relation) : Nil
cannot(action : Symbol, subject : Subject, attributes : Array(Symbol), conditions : Hash | Nil = nil) : Nil
cannot(action : Symbol, subject : Subject, attribute : Symbol) : Nil
cannot(action : Symbol | Nil = nil, subject : Subject | Nil = nil) : Nil
cannot(actions : Array(Symbol), subject : Subject | Array(Subject)) : Nil
cannot(action : Symbol, subjects : Array(Subject)) : Nil
cannot(action : Symbol, subject : Subject, &block : Proc(BlockSubject, Symbol | Nil, Bool)) : Nil
cannot
cannot?(action : Symbol, subject : Subject, attribute : Symbol | Nil = nil) : Bool
clear_aliased_actions
expand_actions(actions : Array(Symbol)) : Array(Symbol)
has_block?(action : Symbol, subject : Subject) : Bool
has_raw_sql?(action : Symbol, subject : Subject) : Bool
merge(other : Ability) : self
permissions

permissions (mirror of ability.rb): renders the same nested hash string the gem's Hash#inspect produces.

permitted_attributes(action : Symbol, subject : Subject) : Array(String)

Attributes permitted for strong parameters: reversed relevant rules add (can) / remove (cannot); a rule without attribute restrictions permits every column. Returns Array(String) — Crystal has no runtime String#to_sym (documented deviation from the gem's symbol array).

relevant_rules(action : Symbol, subject : Subject) : Array(Rule)

relevant rules in evaluation order (last defined first, deduped) — mirrors rules.rb reverse+uniq.

relevant_rules_for_query(action : Symbol, subject : Subject) : Array(Rule)
unauthorized_message(action : Symbol, subject : Subject) : String | Nil

No configured messages / i18n in the port — always the default (kept as a seam mirroring the gem's UnauthorizedMessageResolver).