Method: Blueprinter::Base.view

Defined in:
lib/blueprinter/base.rb

.view(view_name) ⇒ View

Specify a view and the fields it should have. It accepts a view name and a block. The block should specify the fields.

Examples:

Using views

view :extended do
  fields :position, :company
  include_view :normal
  exclude :first_name
end

Parameters:

  • view_name (Symbol)

    the view name

Yield Returns:

Returns:

  • (View)

    a Blueprinter::View object



423
424
425
426
427
428
# File 'lib/blueprinter/base.rb', line 423

def self.view(view_name)
  @current_view = view_collection[view_name]
  view_collection[:default].track_definition_order(view_name)
  yield
  @current_view = view_collection[:default]
end