Class: Blueprinter::Association Private

Inherits:
Field
  • Object
show all
Defined in:
lib/blueprinter/association.rb

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

Instance Attribute Summary

Attributes inherited from Field

#blueprint, #extractor, #method, #name, #options

Instance Method Summary collapse

Methods inherited from Field

#extract, #skip?

Constructor Details

#initialize(method:, name:, blueprint:, view:, parent_blueprint:, extractor: AssociationExtractor.new, options: {}) ⇒ Blueprinter::Association

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.

Parameters:

  • method (Symbol)

    The method to call on the source object to retrieve the associated data

  • name (Symbol)

    The name of the association as it will appear when rendered

  • blueprint (Blueprinter::Base)

    The blueprint to use for rendering the association

  • view (Symbol)

    The view to use in conjunction with the blueprint

  • parent_blueprint (Blueprinter::Base)

    The blueprint that this association is being defined within

  • extractor (Blueprinter::Extractor) (defaults to: AssociationExtractor.new)

    The extractor to use when retrieving the associated data

  • options (Hash) (defaults to: {})


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/blueprinter/association.rb', line 19

def initialize(method:, name:, blueprint:, view:, parent_blueprint:, extractor: AssociationExtractor.new, options: {})
  BlueprintValidator.validate!(blueprint)

  super(
    method,
    name,
    extractor,
    parent_blueprint,
    options.merge(
      blueprint: blueprint,
      view: view,
      association: true
    )
  )
end