Class: Services::CreateServiceDefinitionContext

Inherits:
Object
  • Object
show all
Defined in:
app/contexts/services/create_service_definition_context.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, sd_params, cred_params) ⇒ CreateServiceDefinitionContext

Returns a new instance of CreateServiceDefinitionContext.



11
12
13
14
15
16
# File 'app/contexts/services/create_service_definition_context.rb', line 11

def initialize(owner, sd_params, cred_params)
  @owner = owner
  @sd_params = sd_params
  @cred_params = cred_params
  @owner.extend Services::ServiceDefinitionCreator
end

Instance Attribute Details

#cred_paramsObject

Returns the value of attribute cred_params.



5
6
7
# File 'app/contexts/services/create_service_definition_context.rb', line 5

def cred_params
  @cred_params
end

#ownerObject

Returns the value of attribute owner.



5
6
7
# File 'app/contexts/services/create_service_definition_context.rb', line 5

def owner
  @owner
end

#sd_paramsObject

Returns the value of attribute sd_params.



5
6
7
# File 'app/contexts/services/create_service_definition_context.rb', line 5

def sd_params
  @sd_params
end

Class Method Details

.call(owner, sd_params, cred_params) ⇒ Object



7
8
9
# File 'app/contexts/services/create_service_definition_context.rb', line 7

def self.call(owner, sd_params, cred_params)
  CreateServiceDefinitionContext.new(owner, sd_params, cred_params).call
end

Instance Method Details

#callObject



18
19
20
21
22
# File 'app/contexts/services/create_service_definition_context.rb', line 18

def call
  owner.create(sd_params).tap do | service_definition |
    CreateCredentialContext.call(service_definition, cred_params) if cred_params.present?
  end
end