Method: EasyData.yaml_description_model

Defined in:
lib/easy_data.rb

.yaml_description_model(model_data) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/easy_data.rb', line 24

def self.yaml_description_model(model_data)

  attributes = {}
  associations = {}

  model_data.columns.each do |att|

   if att.primary
     attributes[att.name] = {:privacy => 'Private',:namespace => 'not defined',:property => 'not defined'}
   elsif att.name =~ /_id$/
     attributes[att.name] = "no publication"
   else
     attributes[att.name] = {:privacy => 'Public',:namespace => 'not defined',:property => 'not defined'}
   end

  end  
     
  model_data.reflections.keys.each do |ref|
    associations[ref.to_s] = {:privacy => 'Public',:namespace => 'not defined',:property => 'not defined'}
  end

  {:privacy => "Private",:namespace => "not defined",:property => "not defined","attributes" => attributes,"associations" => associations}
end