Method: Permit::PermitRule#initialize
- Defined in:
- lib/permit/permit_rule.rb
- (PermitRule) initialize(roles, options = {})
Creates a new PermitRule.
:if and :unless conditions may be evaluated for static, dynamic, and named authorizations. They are evaluated after the other rule checks are applied, and only if the rule still matches. The conditionals may make a matching rule not match, but will not make an unmatched rule match. If both :if and :unless are given the :if condition is run first, and if the rule still matches the :unless will be run.
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/permit/permit_rule.rb', line 61 def initialize(roles, = {}) .assert_valid_keys *VALID_OPTION_KEYS @roles = validate_roles(roles).freeze @method = [:who] || [:that] @target_vars = permit_arrayify([:of] || [:on]).uniq.freeze @if = [:if] @unless = [:unless] end |