class Detour::Configuration

Attributes

defined_groups[R]
feature_search_dirs[RW]
feature_search_regex[R]
flaggable_types[RW]

Public Class Methods

new() click to toggle source
# File lib/detour/configuration.rb, line 7
def initialize
  @defined_groups      = {}
  @flaggable_types     = []
  @feature_search_dirs = []
end

Public Instance Methods

feature_search_regex=(regex) click to toggle source

Defines the regular expression used to search for features. It must include a single match group.

@example

Detour.config.feature_search_regex = /\.rollout\? :(\w+)/

@param [Regexp] regex A regex to use to search for feature checks with.

# File lib/detour/configuration.rb, line 20
def feature_search_regex=(regex)
  if regex.is_a? Regexp
    @feature_search_regex = regex
  else
    raise "Feature search regex must be an instance of Regexp"
  end
end
method_missing(method, *args, &block) click to toggle source

Allows for methods of the form `define_user_group` that call the private method `define_group_for_class`. A new group for any `User` records will be created that rollouts can be attached to.

@example

Detour.config.define_user_group :admins do |user|
  user.admin?
end
Calls superclass method
# File lib/detour/configuration.rb, line 36
def method_missing(method, *args, &block)
  if /^define_(?<klass>[a-z0-9_]+)_group/ =~ method
    define_group_for_class(klass.classify, args[0], &block)
  else
    super
  end
end

Private Instance Methods

define_group_for_class(klass, group_name, &block) click to toggle source
# File lib/detour/configuration.rb, line 46
def define_group_for_class(klass, group_name, &block)
  @defined_groups[klass] ||= {}
  @defined_groups[klass][group_name] = Detour::DefinedGroup.new(group_name, block)
end