class SimpleJsonapi::Node::Data::Collection

@!attribute [r] resources

@return [Array<Object>]

Attributes

resources[R]

Public Class Methods

new(resources:, **options) click to toggle source

@param resources [Array<Object>] @param options see {Node::Base#initialize} for additional parameters

Calls superclass method SimpleJsonapi::Node::Base::new
# File lib/simple_jsonapi/node/data/collection.rb, line 10
def initialize(resources:, **options)
  super(options)

  @resources = Array.wrap(resources)

  @resource_nodes = @resources.map do |resource|
    build_child_node(SimpleJsonapi::Node::Resource::Full, resource: resource)
  end
end

Public Instance Methods

as_jsonapi() click to toggle source

@return [Hash{Symbol => Hash}]

# File lib/simple_jsonapi/node/data/collection.rb, line 21
def as_jsonapi
  { data: @resource_nodes.map(&:as_jsonapi) }
end