Sha256: 3857cfd49479324712c73932e5ced855ccb8a8e23280b43c2ac0744c9b9b68c1

Contents?: true

Size: 890 Bytes

Versions: 1

Compression:

Stored size: 890 Bytes

Contents

module MicroServiceClient
	module Concerns
		module Controllers
			module Servers
				extend ActiveSupport::Concern

				def create
					MicroServiceServerInstallJob.perform_later(install_params)

					render :nothing => true, :status => 204
				end

				def destroy
					status = 403

					@server = MicroService::Server.where(uninstall_params).first
					if @server && @server.update_attributes(:uninstalled => true)
						status = 204
					end

					render :nothing => true, :status => status
				end

				private
					def json_params
						ActionController::Parameters.new(JSON.parse(request.body.read))
					end

					def uninstall_params
						data = json_params

						data.permit(
							:id,
							:secret,
						)
					end

					def install_params
						data = json_params

						data.permit(
							:client_id,
							:url,
							:secret,
						)
					end
			end
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
micro_service_client-0.0.3 lib/micro_service_client/concerns/controllers/servers.rb