class

CanCan::Rule

Inherits Reference < Object

Constructors

new(base_behavior : Bool, actions : Symbol | Array(Symbol) | Nil, subjects : Subject | Array(Subject) | Nil, attributes : Array(Symbol) | Nil = nil, conditions : CondVal = nil, block : Proc(BlockSubject, Bool) | Nil = nil, catch_all_block : Proc(Symbol, CatchAllClass, ActiveRecord::Base | Nil, Bool) | Nil = nil, attr_block : Proc(BlockSubject, Symbol | Nil, Bool) | Nil = nil)

Instance methods

actions
attr_block
attributes
attributes_from_conditions
base_behavior
block
call_catch_all_block(action : Symbol, subject : Subject) : Bool
can_rule?
cannot_catch_all?
catch_all?

The gem's catch_all?: blank conditions (nil / empty hash / empty scope) match everything.

catch_all_block
condition_match?(attr : CondAttr, value : CondVal) : Bool
conditions
conditions_empty?
expanded_actions=(actions : Array(Symbol))
inspect

Gem Rule#inspect: #<CanCan::Rulecan [:read], [Article(id: integer, ...)], [:title], {}> (subjects render through Model.inspect).

match_all?
matches_action?(action : Symbol) : Bool
matches_attributes?(attribute : Symbol | Nil) : Bool
matches_conditions?(action : Symbol, subject : Subject, attribute : Symbol | Nil = nil) : Bool

--- ConditionsMatcher ---

matches_conditions_hash?(subject : ActiveRecord::Base, conditions : CondVal) : Bool
matches_conditions_nested?(action : Symbol, parent : ActiveRecord::Base, child : Subject) : Bool

Nested subject (can? :read, parent => child in the gem): the child class drives relevance; conditions are matched against the PARENT through the belongs_to association name, plus the foreign-key condition check against parent.id (AR adapter semantics).

matches_subject?(subject : Subject) : Bool
only_block?
only_raw_sql?
relevant?(action : Symbol, subject : Subject) : Bool

--- Relevant ---

subject_class?(subject : Subject) : Bool
subjects