Open mcamou opened 10 years ago
If you want to access the attributes of the entity pointed to by ImmutableEntityReference, you have to always call it through resolved_entity:
class Address < BaseEntity attribute :street, String attribute :city, String attribute :zip, String end
class User < BaseEntity attribute :name, String reference :address, Address end
So if you want to access a user's address data, you need to do:
user.address.resolved_entity.city user.address.resolved_entity.zip # Or store user.address.resolved_entity in a variable
What I propose is that the ImmutableEntityReference include delegate methods that correspond to the resolved_entity's attributes.
Advantage: Ease of use Disadvantage: A bit of magic, it's not explicit exactly what is happening.
If you want to access the attributes of the entity pointed to by ImmutableEntityReference, you have to always call it through resolved_entity:
So if you want to access a user's address data, you need to do:
What I propose is that the ImmutableEntityReference include delegate methods that correspond to the resolved_entity's attributes.
Advantage: Ease of use Disadvantage: A bit of magic, it's not explicit exactly what is happening.