Class: Moon::Response::JSON::Collection

Inherits:
Moon::Response::JSON show all
Defined in:
lib/moon/response/json/collection.rb

Overview

Moon::Response::JSON::Collection provides a response that contains one single collection.

Instance Attribute Summary

Attributes inherited from Moon::Response::JSON

#hash, #status

Instance Method Summary collapse

Methods inherited from Moon::Response::JSON

#body, #headers

Methods inherited from Base

#body, #headers, #status

Constructor Details

#initialize(collection, formatters) ⇒ Collection

Returns a new instance of Collection.



5
6
7
8
9
10
# File 'lib/moon/response/json/collection.rb', line 5

def initialize(collection, formatters)
  @collection = collection.map do |object|
    Moon::Formatter.hash_for formatters, object
  end
  super 200, @collection
end