Method: Blueprinter::Base.prepare

Defined in:
lib/blueprinter/base.rb

.prepare(object, view_name:, local_options:, root: nil, meta: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This is the magic method that converts complex objects into a simple hash ready for JSON conversion.

Note: we accept view (public interface) that is in reality a view_name, so we rename it for clarity

Raises:



256
257
258
259
260
261
# File 'lib/blueprinter/base.rb', line 256

def self.prepare(object, view_name:, local_options:, root: nil, meta: nil)
  raise BlueprinterError, "View '#{view_name}' is not defined" unless view_collection.view? view_name

  data = prepare_data(object, view_name, local_options)
  prepend_root_and_meta(data, root, meta)
end