Module: Spree::UserManagement
- Extended by:
- ActiveSupport::Concern
- Included in:
- Store
- Defined in:
- app/models/concerns/spree/user_management.rb
Instance Method Summary collapse
-
#add_user(user, role = nil) ⇒ Object
Adds a user to the resource with the default user role If no role is provided, the default user role will be used If a role is provided, it will be used instead of the default user role.
-
#default_user_role ⇒ Object
this can be overridden in the base model to use a different user role, eg.
-
#remove_user(user) ⇒ void
Revokes a user’s access to the resource.
Instance Method Details
#add_user(user, role = nil) ⇒ Object
Adds a user to the resource with the default user role If no role is provided, the default user role will be used If a role is provided, it will be used instead of the default user role
16 17 18 19 |
# File 'app/models/concerns/spree/user_management.rb', line 16 def add_user(user, role = nil) role = role || default_user_role role_users.find_or_create_by!(user: user, role: role) end |
#default_user_role ⇒ Object
this can be overridden in the base model to use a different user role, eg. ‘vendor’
29 30 31 |
# File 'app/models/concerns/spree/user_management.rb', line 29 def default_user_role Spree::Role.default_admin_role end |
#remove_user(user) ⇒ void
This method returns an undefined value.
Revokes a user’s access to the resource
24 25 26 |
# File 'app/models/concerns/spree/user_management.rb', line 24 def remove_user(user) role_users.where(user: user).destroy_all end |