tweak eager loading
authorTom Clegg <tom@clinicalfuture.com>
Mon, 28 Jan 2013 23:09:02 +0000 (15:09 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Mon, 28 Jan 2013 23:09:02 +0000 (15:09 -0800)
app/models/link.rb
app/models/log.rb
app/models/orvos_model.rb
app/models/pipeline_invocation.rb

index 9600d177e0f5f2e58962d0feb7242a1d96649ae5..b17b09c12e30e2d463f9b9d19562da4efcf25227 100644 (file)
@@ -6,6 +6,9 @@ class Link < OrvosModel
   before_create :permission_to_attach_to_objects
   before_update :permission_to_attach_to_objects
 
+  attr_accessor :head
+  attr_accessor :tail
+
   api_accessible :superuser, :extend => :common do |t|
     t.add :tail_kind
     t.add :tail_uuid
@@ -13,6 +16,8 @@ class Link < OrvosModel
     t.add :name
     t.add :head_kind
     t.add :head_uuid
+    t.add :head, :if => :head
+    t.add :tail, :if => :tail
     t.add :properties
   end
 
index 44445d5fab935270c01be4f8a0393c81abca4478..58a8734e5b041fd1c5b0cbf0867ed4a579b6e818 100644 (file)
@@ -4,10 +4,12 @@ class Log < OrvosModel
   include CommonApiTemplate
   serialize :info, Hash
   before_validation :set_default_event_at
+  attr_accessor :object
 
   api_accessible :superuser, :extend => :common do |t|
     t.add :object_kind
     t.add :object_uuid
+    t.add :object, :if => :object
     t.add :event_at
     t.add :event_type
     t.add :summary
index 74f77b10aced72f09747f664fc0e11867418ec6e..c26ac7e0baa2e82bc277a153e504d653ce148d9f 100644 (file)
@@ -20,10 +20,10 @@ class OrvosModel < ActiveRecord::Base
       re = col.name.match /^(.*)_kind$/
       if (re and
           self.respond_to? re[1].to_sym and
-          (auuid = self.send(re[1].to_sym)) and
+          (auuid = self.send((re[1] + '_uuid').to_sym)) and
           (aclass = self.class.kind_class(self.send(col.name.to_sym))) and
           (aobject = aclass.where('uuid=?', auuid).first))
-        self.send((re[1]+'=').to_sym, aobject)
+        self.instance_variable_set('@'+re[1], aobject)
       end
     end
   end
index f475ff770d1f4a4424560a6014cd771881a8dbaa..113411f9a74624fb16683e8b7155194e280e71d3 100644 (file)
@@ -4,12 +4,14 @@ class PipelineInvocation < OrvosModel
   include CommonApiTemplate
   serialize :components, Hash
   belongs_to :pipeline, :foreign_key => :pipeline_uuid, :primary_key => :uuid
+  attr_accessor :pipeline
 
   before_validation :bootstrap_components
   before_validation :update_success
 
   api_accessible :superuser, :extend => :common do |t|
     t.add :pipeline_uuid
+    t.add :pipeline, :if => :pipeline
     t.add :name
     t.add :components
     t.add :success