Sha256: cd329460e6b8492624e5d7253fabbe650ca5b2c78227cfc1cb19b2f735d64d92

Contents?: true

Size: 819 Bytes

Versions: 6

Compression:

Stored size: 819 Bytes

Contents

module {{namespace_module}}
  module Accounts
    module Create
      class Control
        include Shogun::Control
        include Accounts

        def initialize(payload:)
          @normalizer = Normalizer.new(raw: payload.to_hash)
          @validator = Validator.new(data: @normalizer)

          if @validator.valid?
            @model = Model.create(@normalizer.to_hash)

            @presenter = Presenter.new(resource: @model)
            @denormalizer = Denormalizer.new(object: @presenter)
            @status = OK
          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

Version Path
shogun-6.4.2 scaffold/new/project/lib/namespace/accounts/create/control.rb
shogun-6.4.1 scaffold/new/project/lib/namespace/accounts/create/control.rb
shogun-6.4.0 scaffold/new/project/lib/namespace/accounts/create/control.rb
shogun-6.3.0 scaffold/new/project/lib/namespace/accounts/create/control.rb
shogun-6.2.3 scaffold/new/project/lib/namespace/accounts/create/control.rb
shogun-6.2.2 scaffold/new/project/lib/namespace/accounts/create/control.rb