Method: Blueprinter::Base.include_view

Defined in:
lib/blueprinter/base.rb

.include_view(view_name) ⇒ Array<Symbol>

Specify another view that should be mixed into the current view.

Examples:

Including a normal view into an extended view.

class UserBlueprint < Blueprinter::Base
  # other code...
  view :normal do
    fields :first_name, :last_name
  end
  view :extended do
    include_view :normal # include fields specified from above.
    field :description
  end
  #=> [:first_name, :last_name, :description]
end

Parameters:

  • view_name (Symbol)

    the view to mix into the current view.

Returns:

  • (Array<Symbol>)

    an array of view names.



335
336
337
# File 'lib/blueprinter/base.rb', line 335

def self.include_view(view_name)
  current_view.include_view(view_name)
end