No commit activity in last 3 years
No release in over 3 years
Class for streaming JSON API via Grape stream
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 1.1.0
~> 0.6.3
~> 10.0

Runtime

>= 0.16.2, ~> 0.16
>= 0.13.0, ~> 0.13
 Project Readme

grape_json_api_streamer

Based heavily on the suggestion by raulpopadineti at ruby-grape/grape#1392 which is used for streaming Grape::Entity, this class provides a way to stream JSON::API using the jsonapi-serializers gem in grape.

Example

require 'grape'
require 'grape/json_api/streamer'

class Model
  def initialize(id)
    @id = id
  end

  def id
    @id
  end

  def foo
    'bar'
  end
end

class ModelSerializer
  include JSONAPI::Serializer

  attribute :foo
end

class MockAPI < Grape::API
  format :json
  content_type :json, 'application/json;charset=UTF-8'

  resource :foo do
    get do
      model  = Model.new(1)
      model2 = Model.new(2)
      stream Grape::JSONAPI::Streamer.new([model, model2])
    end
  end
end