Friday 15 March 2013

Ruby Datamapper table inheritance with associations -


I started learning and what I liked about it is that I can write my model with real heritage.

Now I wonder, if it is possible to be more advanced about:

  Class events include DataMaper :: resource property: ID, serial property: launches , DateTime Property: Type, Discrimination End Square Talk & lt; Event Properties: Title, String related_to: Meeting and Class Meeting & lt; The event is near: the negotiation ends  

that code fails to create the : title column talk and of course, the discriminating column It is of little value here, because of the database view, both talk and meetings .

So, finally, I want to share the same properties as defined in talk and meeting in event With possible additional properties and 0..1: n relationship (I can talk with sevro in one meeting but without meeting without interaction.) Is this column without leaving the definitions and / or Virat Is there any way to complete?

Edit

To give another example: The part that I like about inheritance, that is the usual event Can be questioned separately, therefore, when I want to know, if there is a certain : beginning on the date, then I do not need to see two or more tables, but Only the event table, the following structure can fit my needs. In the class event, the DataMaper :: resource property is included in the: ID, serial property: start, DateTimeCall DataMaper in Talk Talk :: resource property: ID, serial property: title, string related_to: Event Attende: In the meeting and class meeting, DataMaper :: resource includes the property: id, serial related_to: event is n: the negotiation ends

However, in order to use it, Every left And I have to manually create a event , I want to create or edit a talk , that's it, I'll call talk.begin or Talk.create (: start = & gt; time.No) can . Is there no way around it that without patching and merging properties to all the facts? When using the model, I do not want to be reminded of the underlying structure.

If you want to repeat the attributes of the event in talk and meeting, then you take it into a module Go to:

  Module EventFields def self.included (base) in database base.class_eval :: Resources includes the property: id, datamaker :: type :: serial property: initiation, datetime # Other fields here include EventFilled property in End End and Class Talk: Title, Related to String: Meeting End This will give you different tables, but this means that the repetition will be reduced, near the eventfield, in the meeting meeting, the negotiation ends  

.


No comments:

Post a Comment