Module: Troles::Common::Config::ValidRoles
- Defined in:
- lib/troles/common/config/valid_roles.rb
Instance Method Summary collapse
-
#add_valid_roles(*roles) ⇒ Object
Add a list of valid roles.
-
#valid_roles ⇒ Array<Symbol>
Get the list of valid roles.
-
#valid_roles=(*roles) ⇒ Object
Set a list of valid roles.
Instance Method Details
#add_valid_roles(*roles) ⇒ Object
Add a list of valid roles
12 13 14 |
# File 'lib/troles/common/config/valid_roles.rb', line 12 def add_valid_roles *roles valid_roles =valid_roles & roles end |
#valid_roles ⇒ Array<Symbol>
Get the list of valid roles
28 29 30 31 |
# File 'lib/troles/common/config/valid_roles.rb', line 28 def valid_roles raise "No valid roles defined" if !@valid_roles || @valid_roles.empty? @valid_roles end |
#valid_roles=(*roles) ⇒ Object
Set a list of valid roles
18 19 20 21 22 23 24 |
# File 'lib/troles/common/config/valid_roles.rb', line 18 def valid_roles= *roles vrs = roles.flatten.map{|r| r.to_s.alpha_numeric}.map(&:to_sym).uniq raise ArgumentError, "The #{strategy} strategy can only accept 2 valid roles" if (vrs.size > 2) && strategy == :bit_one raise ArgumentError, "The role names you want to be valid are not valid role names. Must be alphanumeric, was: #{roles.flatten}" if vrs.empty? @valid_roles ||= vrs end |