Class: Notee::Authority
- Inherits:
-
Object
- Object
- Notee::Authority
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/notee/authority.rb
Defined Under Namespace
Classes: AuthorityError
Constant Summary collapse
- TARGET_ARR =
['Post', 'Category', 'Image', 'User']
Class Method Summary collapse
Class Method Details
.check(crud, new_model_obj) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/notee/authority.rb', line 10 def check(crud, new_model_obj) check_deleted role = get_role case role when 'writer' then writer(crud, new_model_obj) when 'editor' then editor(crud, new_model_obj) when 'manager' then manager(crud, new_model_obj) when 'root' then root_user(crud, new_model_obj) else end end |
.get_role ⇒ Object
29 30 31 32 |
# File 'app/models/notee/authority.rb', line 29 def get_role token = Token.find_by(access_token: Thread.current[:request].session[:access_token]) return token.user.role end |
.get_user_id ⇒ Object
34 35 36 37 |
# File 'app/models/notee/authority.rb', line 34 def get_user_id token = Token.find_by(access_token: Thread.current[:request].session[:access_token]) return token.user.id end |