Open mcamou opened 10 years ago
It's OK that "references" and "multi_references" have an optional class to point to, so that the attribute's name can be more flexible. However, IMHO doing the same thing with "children" could be dangerous, since here we'd be dealing with an inheritance scenario:
class Department < BaseEntity
#...
end
class Company < BaseEntity
children :local_department, :remote_department
#...
end
class LocalDepartment < Department; parent :company; end
class RemoteDepartment < Department; parent :company; end
In the scenario above, the serialization to a relational DB could be implemented via an InheritanceMapper
that handles either one of these:
WDYT?
We can have another scenario:
class Department < BaseEntity
children :employees
children :managers, Employee
end
class Employee < BaseEntity
parent :department
end
This could be resolved either by:
(using CTI or STI)
class Employee < BaseEntity
parent :department
end
class Manager < Employee
def self.promote(an_employee)
# Use an_employee as a prototype
end
end
Or (using references):
class Department < BaseEntity
children :employees
reference :manager, Employee
end
Currently the class name of the children entities is inferred from the name. It would be useful to be able to rename the children (similar to the way references work). For example: