Class: Detour::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/detour/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
11
# File 'lib/detour/configuration.rb', line 7

def initialize
  @defined_groups      = {}
  @flaggable_types     = []
  @feature_search_dirs = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

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.

Examples:

Detour.config.define_user_group :admins do |user|
  user.admin?
end


36
37
38
39
40
41
42
# 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

Instance Attribute Details

#defined_groupsObject (readonly)

Returns the value of attribute defined_groups.



2
3
4
# File 'lib/detour/configuration.rb', line 2

def defined_groups
  @defined_groups
end

#feature_search_dirsObject

Returns the value of attribute feature_search_dirs.



5
6
7
# File 'lib/detour/configuration.rb', line 5

def feature_search_dirs
  @feature_search_dirs
end

#feature_search_regexObject

Returns the value of attribute feature_search_regex.



3
4
5
# File 'lib/detour/configuration.rb', line 3

def feature_search_regex
  @feature_search_regex
end

#flaggable_typesObject

Returns the value of attribute flaggable_types.



4
5
6
# File 'lib/detour/configuration.rb', line 4

def flaggable_types
  @flaggable_types
end