Class: ApiMaker::MemberCommandService
- Inherits:
-
CommandService
- Object
- ServicePattern::Service
- ApplicationService
- CommandService
- ApiMaker::MemberCommandService
- Defined in:
- app/services/api_maker/member_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
Constructor Details
This class inherits a constructor from ApiMaker::CommandService
Instance Method Details
#constant ⇒ Object
18 19 20 |
# File 'app/services/api_maker/member_command_service.rb', line 18 def constant @constant ||= "Commands::#{namespace}::#{@command_name.camelize}".constantize end |
#execute ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/services/api_maker/member_command_service.rb', line 2 def execute ability_name = @command_name.to_sym collection = model_class.accessible_by(@ability, ability_name).where(model_class.primary_key => ids) constant.execute_in_thread!( ability: ability, args: args, collection: collection, commands: commands, command_response: command_response, controller: controller ) ServicePattern::Response.new(success: true) end |
#ids ⇒ Object
22 23 24 |
# File 'app/services/api_maker/member_command_service.rb', line 22 def ids @commands.values.map { |command| command.fetch("primary_key") } end |