add /nodes status page
[arvados.git] / app / models / metadatum.rb
1 class Metadatum < ActiveRecord::Base
2   serialize :info, Hash
3
4   before_validation :populate_native_target
5   include AssignUuid
6
7   def info
8     @info ||= Hash.new
9     super
10   end
11
12   protected
13
14   def populate_native_target
15     begin
16       class_name = target_kind.
17         sub(/^orvos#/,'').
18         classify
19       self.native_target_type = class_name
20       self.native_target_id = class_name.
21         constantize.
22         where('uuid = ?', target_uuid).
23         first.
24         id
25     rescue
26       self.native_target_type = nil
27       self.native_target_id = nil
28     end
29   end
30 end