Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Blueprinter

NOTE This is a WIP for API V2!

Blueprinter is a JSON serializer for your business objects. It is designed to be simple, flexible, and performant.

Upgrading from 1.x? Read the upgrade guide!

Installation

bundle add blueprinter

See rubydoc.info/gems/blueprinter for generated API documentation.

Basic Usage

class WidgetBlueprint < ApplicationBlueprint
  field :name
  object :category, CategoryBlueprint
  collection :parts, PartBlueprint

  view :extended do
    field :description
    object :manufacturer, CompanyBlueprint
    collection :vendors, CompanyBlueprint
  end
end

# Render the default view to JSON
WidgetBlueprint.render(widget).to_json

# Render the extended view to a Hash
WidgetBlueprint[:extended].render(widget).to_hash

Look interesting? Learn the DSL!