Sha256: 334da40c6551540f83e153e025404c0a017313e31037fd9bac0f31e1388cbe34
Contents?: true
Size: 1.24 KB
Versions: 6
Compression:
Stored size: 1.24 KB
Contents
module {{namespace_module}} module {{resource_module}} module Destroy class Control include Shogun::Control include {{resource_module}} def initialize(payload:) @normalizer = Normalizer.new(raw: payload.to_hash) @validator = Validator.new(data: @normalizer) if @validator.valid? @session = Sessions::Model.find_by(id: @normalizer.session) @model = Model.find_by(id: @normalizer.id) @authorizer = Authorizer.new(requester: @session, resource: @model) case when @model && @authorizer.allowed? @model.destroy @presenter = Presenter.new(resource: @model, meta: @normalizer.as_meta) @denormalizer = Denormalizer.new(object: @presenter) @status = OK when @model && @authorizer.denied? @status = UNAUTHORIZED else @status = NOT_FOUND end else @presenters = Shogun::Presenters.new(resources: @validator.invalids, cast: Errors::Presenter) @denormalizer = Errors::Denormalizer.new(object: @presenters) @status = UNPROCESSABLE_ENTITY end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems