CanCan
End-of-program codegen:
- CanCan.model_* dispatchers: per-operation dispatch over the registered
models. Each case branch calls on the LITERAL class — the static
ActiveRecord::Base.classtype does not know per-model methods generated by active_record_cr's codegen (same constraint devise_cr solves with typed procs), and unions/params collapse the metaclass. - cancan_action: action-string → Symbol dispatch for every registered controller (Crystal has no String#to_sym; actions are compile-time known). Runs alongside action_pack's own finished hook.
Constants
Compile-time model registry: {underscored resource name, class}.
Class methods
nil-returning variants for the core Rule matcher (nested subjects
work without registration via the class-name fallback). NOTE:
if/elsif with == — case x; when SomeClass is an is_a? check
on instances and never matches class objects.
ActionController::Parameters::Value → ParamValue.
Hash conditions → AND-ed SQL. Nested hashes become (NOT) EXISTS subqueries through the association join (same result sets as the gem's LEFT JOIN aliasing).
Substitutes a fragment's ? placeholders with inlined literals.
SQL literal for a condition value (strings escaped by doubling quotes).
Renders one rule's conditions as a self-contained WHERE fragment (literals inlined, strings escaped). nil for blank conditions (matches everything).
Converts a user-written conditions literal (Hash(String, Bool) etc.) into Hash(String, CondVal) — Crystal generics are invariant.
Macros
Nested types
- CanCan::Ability
- CanCan::AccessDenied
- CanCan::AccessibleBy
- CanCan::BlockAndConditionsError
- CanCan::BlockSubject
- CanCan::CatchAllClass
- CanCan::CondAttr
- CanCan::CondVal
- CanCan::ControllerAdditions
- CanCan::ControllerResource
- CanCan::Error
- CanCan::ParamHash
- CanCan::ParamValue
- CanCan::RawScope
- CanCan::Rule
- CanCan::RulesCompressor
- CanCan::SkipOptions
- CanCan::Subject