Sha256: ffab5dde78c9a446c414a25a90cbfacd4394f3b3e3102777721044a592009a0e
Contents?: true
Size: 989 Bytes
Versions: 6
Compression:
Stored size: 989 Bytes
Contents
module {{namespace_module}} module {{resource_module}} module Show 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? @model = Model.find_by(id: @normalizer.id) if @model @presenter = Presenter.new(resource: @model, meta: @normalizer.as_meta) @denormalizer = Denormalizer.new(object: @presenter, fields: @normalizer.fields) @status = OK 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