Module: TroleGroups::Config::ValidRoleGroups

Defined in:
lib/trole_groups/config/valid_role_groups.rb

Instance Method Summary collapse

Instance Method Details

#add_valid_rolegroups(*rolegroups) ⇒ Object



4
5
6
# File 'lib/trole_groups/config/valid_role_groups.rb', line 4

def add_valid_rolegroups *rolegroups
  valid_rolegroups =valid_rolegroups & rolegroups
end

#valid_rolegroupsObject



15
16
17
18
# File 'lib/trole_groups/config/valid_role_groups.rb', line 15

def valid_rolegroups
  raise "No valid rolegroups defined" if !@valid_rolegroups || @valid_rolegroups.empty?
  @valid_rolegroups      
end

#valid_rolegroups=(*rolegroups) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
13
# File 'lib/trole_groups/config/valid_role_groups.rb', line 8

def valid_rolegroups= *rolegroups
  vrs = rolegroups.flatten.map{|r| r.to_s.alpha_numeric}.map(&:to_sym).uniq
  raise ArgumentError, "The #{strategy} strategy can only accept 2 valid rolegroups" if (vrs.size > 2) && strategy == :bit_one
  raise ArgumentError, "The rolegroup names you want to be valid are not valid rolegroup names. Must be alphanumeric, was: #{rolegroups.flatten}" if vrs.empty?
  @valid_rolegroups ||= vrs
end