Module: Arturo::SpecialHandling

Extended by:
ActiveSupport::Concern
Included in:
FeatureMethods
Defined in:
lib/arturo/special_handling.rb

Overview

Adds whitelist and blacklist support to individual features by name or for all features. Blacklists override whitelists. (In the world of Apache, Features are “(deny,allow)”.) Blacklists and whitelists can be defined before the feature exists and are not persisted, so they are best defined in initializers. This is particularly important if your application runs in several different processes or on several servers.

Examples:

# allow admins for some_feature:
Arturo::Feature.whitelist(:some_feature) do |user|
  user.is_admin?
end

# disallow for small accounts for another_feature:
Arturo::Feature.blacklist(:another_feature) do |user|
  user..small?
end

# allow large accounts access to large features:
Arturo::Feature.whitelist do |feature, user|
  feature.symbol.to_s =~ /^large/ && user..large?
end