Class: AuthManager::Adder

Inherits:
Constants show all
Defined in:
lib/auth_manager.rb,
lib/auth_manager/adder/adder.rb

Constant Summary

Constants inherited from Constants

Constants::APPS, Constants::USERS

Class Method Summary collapse

Class Method Details

.save?(given_user, option = {user: true, app: false}) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/auth_manager/adder/adder.rb', line 6

def self.save?(given_user, option={user: true, app: false})
  user = option.fetch(:user) || false
  app  = option.fetch(:app) || false
  response = {}
  #section to allow new validation class to work with a hash
  hash = hash_format_of(given_user, option)
  #end of section
  #hash for base redis_sadd
  validation_mess = AuthManager::Validation.validate_param( hash )
  hash_for_base = { object: hash[:object], list: 'users' } if hash[:option][:user]
  hash_for_base = { object: hash[:object], list: 'applications' } if hash[:option][:app]
  response = AuthManager::Base.redis_sadd(hash_for_base) if (validation_mess[:code] == 200)
  response[:code] == 200 ? true : false
end