Sha256: 5220b2500a65bfb78c6a7a7a019fc08dc8a20cd7b80c218ded400eec84c17755
Contents?: true
Size: 1.18 KB
Versions: 5
Compression:
Stored size: 1.18 KB
Contents
# Custom Base Policy `ActionPolicy::Base` is a combination of all available policy extensions with the default configuration. It looks like this: <span style="display:none;"># rubocop:disable Style/ClassAndModuleChildren</span> ```ruby class ActionPolicy::Base include ActionPolicy::Policy::Core include ActionPolicy::Policy::Authorization include ActionPolicy::Policy::Reasons include ActionPolicy::Policy::PreCheck include ActionPolicy::Policy::Aliases include ActionPolicy::Policy::CachedApply # ActionPolicy::Policy::Defaults module adds the following authorize :user default_rule :manage? alias_rule :new?, to: :create? def index? false end def create? false end def manage? false end end ``` <span style="display:none;"># rubocop:enable Style/ClassAndModuleChildren</span> You can write your `ApplicationPolicy` from scratch instead of inheriting from `ActionPolicy::Base` if the defaults above do not fit your needs. The only required component is `ActionPolicy::Policy::Core`: ```ruby # minimal ApplicationPolicy class ApplicationPolicy include ActionPolicy::Policy::Core end ``` The `Core` module provides `apply` and `allowed_to?` methods.
Version data entries
5 entries across 5 versions & 1 rubygems