Class: Keys::CreateService
- Inherits:
-
BaseService
- Object
- BaseService
- Keys::CreateService
- Defined in:
- app/services/keys/create_service.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
Attributes inherited from BaseService
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user, params = {}) ⇒ CreateService
constructor
A new instance of CreateService.
Methods inherited from BaseService
Constructor Details
#initialize(current_user, params = {}) ⇒ CreateService
Returns a new instance of CreateService.
7 8 9 10 11 12 |
# File 'app/services/keys/create_service.rb', line 7 def initialize(current_user, params = {}) @current_user = current_user @params = params @ip_address = @params.delete(:ip_address) @user = params.delete(:user) || current_user end |
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
5 6 7 |
# File 'app/services/keys/create_service.rb', line 5 def current_user @current_user end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 |
# File 'app/services/keys/create_service.rb', line 14 def execute key = user.keys.create(params) notification_service.new_key(key) if key.persisted? key end |