Module: Arturo::SpecialHandling

Included in:
Feature
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

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



28
29
30
# File 'lib/arturo/special_handling.rb', line 28

def self.included(base)
  base.extend Arturo::SpecialHandling::ClassMethods
end