Sha256: af3fd60021e1a0ebe9a47a60f06be0d81799bba541208e5de4c293939aef47c5

Contents?: true

Size: 491 Bytes

Versions: 2

Compression:

Stored size: 491 Bytes

Contents

module ActsAsApi
  module Collection
    # The collection checks all its items if they respond to the +as_api_response+ method.
    # If they do, the result of this method will be collected.
    # If they don't, the item itself will be collected.
    def as_api_response(api_template, options = {})
      collect do |item|
        if item.respond_to?(:as_api_response)
          item.as_api_response(api_template, options)
        else
          item
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acts_as_api-1.0.1 lib/acts_as_api/collection.rb
acts_as_api-1.0.0 lib/acts_as_api/collection.rb