Class: Applications::CreateService

Inherits:
Object
  • Object
show all
Defined in:
app/services/applications/create_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_user, params) ⇒ CreateService

Returns a new instance of CreateService.


7
8
9
10
# File 'app/services/applications/create_service.rb', line 7

def initialize(current_user, params)
  @current_user = current_user
  @params = params.except(:ip_address)
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user


5
6
7
# File 'app/services/applications/create_service.rb', line 5

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params


5
6
7
# File 'app/services/applications/create_service.rb', line 5

def params
  @params
end

Instance Method Details

#execute(request) ⇒ Object

EE would override and use `request` arg


13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/applications/create_service.rb', line 13

def execute(request)
  @application = Doorkeeper::Application.new(params)

  unless params[:scopes].present?
    @application.errors.add(:base, _("Scopes can't be blank"))

    return @application
  end

  @application.save
  @application
end