Sha256: 4fff4f37a1f1535803ce2e461f8ed4b05c0cb01de90ec7fc78b08f380305af63

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

module {{namespace_module}}
  module Accounts
    module Update
      class Normalizer
        include Shogun::Normalizer
        include Accounts

        METADATA = %w|id|
        ATTRIBUTES = %w|signature name email username|

        def initialize(raw:)
          @id = raw["id"]

          if raw["rack.authentication"] && raw["rack.authentication"]["sessions"]
            @session = raw["rack.authentication"]["sessions"]["id"]
          end

          if raw[NAMESPACE]
            @signature = raw[namespace]["signature"]
            @name = raw[namespace]["name"]
            @email = raw[namespace]["email"]
            @username = raw[namespace]["username"]
          end
        end

        def id
          @id
        end

        def session
          @session
        end

        def signature
          @signature.strip if @signature.is_a?(String)
        end

        def name
          @name.strip if @name.is_a?(String)
        end

        def email
          @email.strip if @email.is_a?(String)
        end

        def username
          @username.strip if @username.is_a?(String)
        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/update/normalizer.rb
shogun-6.4.1 scaffold/new/project/lib/namespace/accounts/update/normalizer.rb
shogun-6.4.0 scaffold/new/project/lib/namespace/accounts/update/normalizer.rb
shogun-6.3.0 scaffold/new/project/lib/namespace/accounts/update/normalizer.rb
shogun-6.2.3 scaffold/new/project/lib/namespace/accounts/update/normalizer.rb
shogun-6.2.2 scaffold/new/project/lib/namespace/accounts/update/normalizer.rb