Class: Apiwork::Adapter::Wrapper::Member::Default

Inherits:
Base
  • Object
show all
Defined in:
lib/apiwork/adapter/wrapper/member/default.rb

Overview

Default member response wrapper.

Wraps a serialized record under a singular root key with optional meta and capability metadata.

Examples:

Configuration

class MyAdapter < Adapter::Base
  member_wrapper Wrapper::Member::Default
end

Output

{
  "invoice": { "id": 1, "number": "INV-001" },
  "meta": { ... }
}

Instance Attribute Summary

Attributes inherited from Base

#meta, #metadata, #root_key

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods inherited from Base

#initialize, shape, wrap

Constructor Details

This class inherits a constructor from Apiwork::Adapter::Wrapper::Member::Base

Instance Method Details

#wrapObject



29
30
31
32
33
34
35
# File 'lib/apiwork/adapter/wrapper/member/default.rb', line 29

def wrap
  {
    root_key.singular.to_sym => data,
    meta: meta.presence,
    **,
  }.compact
end