Method: Blueprinter::Base.include_views

Defined in:
lib/blueprinter/base.rb

.include_views(*view_names) ⇒ Array<Symbol>

Specify additional views that should be mixed into the current view.

@param view_name [Array<Symbol>] the views to mix into the current view.

Examples:

Including the normal and special views into an extended view.

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

Returns:

  • (Array<Symbol>)

    an array of view names.



361
362
363
# File 'lib/blueprinter/base.rb', line 361

def self.include_views(*view_names)
  current_view.include_views(view_names)
end