Sha256: 268d6a0c346b3a2bd6e833d27ae43263609f60a2ea1c73c1004068f8991d4b83

Contents?: true

Size: 989 Bytes

Versions: 6

Compression:

Stored size: 989 Bytes

Contents

module {{namespace_module}}
  module Accounts
    module List
      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?
            @models = Model.limit(@normalizer.limit).where(@normalizer.filters).includes(@normalizer.includes)
            @presenters = Shogun::Presenters.new(resources: @models, cast: Presenter, includes: @normalizer.includes, meta: @normalizer.as_meta)
            @denormalizer = Denormalizer.new(object: @presenters, fields: @normalizer.fields)
            @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/list/control.rb
shogun-6.4.1 scaffold/new/project/lib/namespace/accounts/list/control.rb
shogun-6.4.0 scaffold/new/project/lib/namespace/accounts/list/control.rb
shogun-6.3.0 scaffold/new/project/lib/namespace/accounts/list/control.rb
shogun-6.2.3 scaffold/new/project/lib/namespace/accounts/list/control.rb
shogun-6.2.2 scaffold/new/project/lib/namespace/accounts/list/control.rb