Class: ApiMaker::DestroyCommandService

Inherits:
CommandService show all
Defined in:
app/services/api_maker/destroy_command_service.rb

Instance Attribute Summary

Attributes inherited from CommandService

#ability, #args, #command_name, #command_response, #commands, #controller, #resource_name

Instance Method Summary collapse

Methods inherited from CommandService

#initialize, #model_class, #namespace, #resource

Methods inherited from ApplicationService

#api_maker_json

Constructor Details

This class inherits a constructor from ApiMaker::CommandService

Instance Method Details

#collectionObject



15
16
17
# File 'app/services/api_maker/destroy_command_service.rb', line 15

def collection
  @collection ||= model_class.accessible_by(@ability, :destroy).where(model_class.primary_key => ids)
end

#executeObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'app/services/api_maker/destroy_command_service.rb', line 2

def execute
  ApiMaker::DestroyCommand.execute_in_thread!(
    ability: ability,
    args: args,
    collection: collection,
    commands: commands,
    command_response: command_response,
    controller: controller
  )

  ServicePattern::Response.new(success: true)
end

#idsObject



19
20
21
# File 'app/services/api_maker/destroy_command_service.rb', line 19

def ids
  @commands.values.map { |command| command.fetch("primary_key") }
end