Class: Pragma::Decorator::Association::Adapter::Poro Private

Inherits:
Base
  • Object
show all
Includes:
Adaptor
Defined in:
lib/pragma/decorator/association/adapter/poro.rb

Overview

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.

This is the fallback adapter that is used when no other adpater is compatible with a model. It simply calls #id on the associated object to get the PK and returns the associated object itself when expanding.

Instance Attribute Summary

Attributes inherited from Base

#bond

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Pragma::Decorator::Association::Adapter::Base

Class Method Details

.supports?(_model) ⇒ Boolean

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.

Returns whether the adapter supports the model.

Since this is the default adapter, this always returns true.

Parameters:

  • _model (Object)

    the model to check

Returns:

  • (Boolean)

    always true



23
24
25
# File 'lib/pragma/decorator/association/adapter/poro.rb', line 23

def supports?(_model)
  true
end

Instance Method Details

#full_objectObject

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.

Returns the expanded associated object.

This adapter simply returns the associated object itself.

Returns:

  • (Object)

    the associated object



43
44
45
# File 'lib/pragma/decorator/association/adapter/poro.rb', line 43

def full_object
  associated_object
end

#primary_keyInteger|String|NilClass

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.

Returns the PK of the associated object.

This adapter simply calls #id on the associated object or returns nil if there is no associated object.

Returns:

  • (Integer|String|NilClass)

    the PK of the associated object



34
35
36
# File 'lib/pragma/decorator/association/adapter/poro.rb', line 34

def primary_key
  associated_object&.id
end