Module: Troles::Common::Api::Validation

Defined in:
lib/troles/common/api/validation.rb

Instance Method Summary collapse

Instance Method Details

#check_valid_role?(role) ⇒ Symbol, false

Returns the role if it’s valid, false if not

Returns:

  • (Symbol, false)

    returns the role if it’s valid, false if not



10
11
12
13
# File 'lib/troles/common/api/validation.rb', line 10

def check_valid_role? role
  return role if valid_roles.include? role.to_sym
  false
end

#check_valid_roles?(*roles) ⇒ Array<Symbol>

Returns the valid roles or empty list if no valid roles

Returns:

  • (Array<Symbol>)

    returns the valid roles or empty list if no valid roles



16
17
18
# File 'lib/troles/common/api/validation.rb', line 16

def check_valid_roles? *roles
  valid_roles & roles.to_symbols     
end