class Ronflex::Rule
a model matches the type and satisfies the condition for a particular request.
a custom condition defined by a block of logic. The rule can then evaluate whether
Represents a rule that associates a specific type (e.g., ‘:admin`, `:guest`) with
Class Rule
def initialize(type, &block)
- Yieldparam: request - The request being evaluated (e.g., an HTTP request object).
Yieldparam: model - The model being evaluated (e.g., a user or role).
Other tags:
- Yield: - The block defining the rule's logic. It is executed to determine
Parameters:
-
type
(Symbol, String
) -- The type of model this rule applies to.
def initialize(type, &block) @type = type @rule = block end
def matches?(model, request)
-
(Boolean)
- `true` if the model matches the rule's type and satisfies the block's logic, `false` otherwise.
Parameters:
-
request
(Object
) -- The request to check (e.g., an HTTP request object). -
model
(Object
) -- The model to check (e.g., a user or role).
def matches?(model, request) model == type && rule.call(model, request) end