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 = []
  @grep_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


21
22
23
24
25
26
27
# File 'lib/detour/configuration.rb', line 21

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

#default_flaggable_class_nameObject

Returns the value of attribute default_flaggable_class_name.



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

def default_flaggable_class_name
  @default_flaggable_class_name
end

#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

#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

#grep_dirsObject

Returns the value of attribute grep_dirs.



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

def grep_dirs
  @grep_dirs
end