Module: Sequel::Privacy::PolicyDSL
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/sequel/privacy/policy_dsl.rb
Overview
DSL for defining custom policies. Extend your policy module with this to get the ‘policy` method.
Example:
module P
extend Sequel::Privacy::PolicyDSL
AlwaysDeny = Sequel::Privacy::BuiltInPolicies::AlwaysDeny
policy :AllowAdmins, ->(actor) {
allow if actor.is_role?(:admin)
}, 'Allow admin users', cacheable: true
end
Instance Method Summary collapse
Instance Method Details
#policy(name, lam, comment = nil, cacheable: true, single_match: false) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/sequel/privacy/policy_dsl.rb', line 43 def policy(name, lam, comment = nil, cacheable: true, single_match: false) p = Policy.new(&lam).setup( policy_name: name, comment: comment, cacheable: cacheable, single_match: single_match ) const_set(name, p) end |