Sha256: 2fd730d309f3a9723f8907b2771205e96c0b339878287130b6bb5355dec8cad3

Contents?: true

Size: 818 Bytes

Versions: 6

Compression:

Stored size: 818 Bytes

Contents

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

        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/sessions/create/control.rb
shogun-6.4.1 scaffold/new/project/lib/namespace/sessions/create/control.rb
shogun-6.4.0 scaffold/new/project/lib/namespace/sessions/create/control.rb
shogun-6.3.0 scaffold/new/project/lib/namespace/sessions/create/control.rb
shogun-6.2.3 scaffold/new/project/lib/namespace/sessions/create/control.rb
shogun-6.2.2 scaffold/new/project/lib/namespace/sessions/create/control.rb