Association
Represents an association defined on a representation.
Associations map to model relationships and define serialization behavior. Used by adapters to build contracts and serialize records.
Example
association = InvoiceRepresentation.associations[:customer]
association.name # => :customer
association.type # => :belongs_to
association.representation_class # => CustomerRepresentationInstance Methods
#collection?
#collection?
Whether this association is a collection.
Returns
Boolean
#deprecated?
#deprecated?
Whether this association is deprecated.
Returns
Boolean
#description
#description
The description for this association.
Returns
String, nil
#example
#example
The example for this association.
Returns
Object, nil
#filterable?
#filterable?
Whether this association is filterable.
Returns
Boolean
#include
#include
The inclusion strategy for this association.
Returns
Symbol
#model_class
#model_class
The model class for this association.
Returns
Class<ActiveRecord::Base>
#name
#name
The name for this association.
Returns
Symbol
#nullable?
#nullable?
Whether this association is nullable.
Returns
Boolean
#polymorphic
#polymorphic
The polymorphic representations for this association.
Returns
Array<Class<Representation::Base>>, nil
#polymorphic?
#polymorphic?
Whether this association is polymorphic.
Returns
Boolean
#representation_class
#representation_class
Uses explicit representation: if set, otherwise inferred from the model.
Returns
Class<Representation::Base>, nil
#singular?
#singular?
Whether this association is singular.
Returns
Boolean
#sortable?
#sortable?
Whether this association is sortable.
Returns
Boolean
#writable?
#writable?
Whether this association is writable.
Returns
Boolean
See also
#writable_for?
#writable_for?(action)
Whether this association is writable for the given action.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
action | Symbol<:create, :update> | The action. |
Returns
Boolean
See also