class HecksAdapters::ResourceServer::Methods::Update
Update
a resource
Attributes
application_adapter[RW]
body[RW]
command[RW]
id[RW]
module_name[RW]
result[R]
Public Class Methods
new(application_adapter:)
click to toggle source
# File lib/methods/update.rb, line 9 def initialize(application_adapter:) @application_adapter = application_adapter end
Public Instance Methods
call(id:, body:, module_name:)
click to toggle source
# File lib/methods/update.rb, line 13 def call(id:, body:, module_name:) @id = id @body = body.read @module_name = module_name.to_sym run_command convert_to_json self end
status()
click to toggle source
# File lib/methods/update.rb, line 22 def status return 500 if command.result[:errors].count.positive? 200 end
Private Instance Methods
convert_to_json()
click to toggle source
# File lib/methods/update.rb, line 31 def convert_to_json @result = JSON.generate(command.to_h) end
params()
click to toggle source
# File lib/methods/update.rb, line 43 def params JSON.parse(body, symbolize_names: true).merge(id: id) end
run_command()
click to toggle source
# File lib/methods/update.rb, line 35 def run_command @command = application_adapter.call( module_name: module_name, command_name: :update, args: params ) end