add /orvos/v1/schema
authorTom Clegg <tom@clinicalfuture.com>
Tue, 15 Jan 2013 22:54:43 +0000 (14:54 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Tue, 15 Jan 2013 22:55:26 +0000 (14:55 -0800)
app/controllers/orvos/v1/schema_controller.rb [new file with mode: 0644]
config/routes.rb

diff --git a/app/controllers/orvos/v1/schema_controller.rb b/app/controllers/orvos/v1/schema_controller.rb
new file mode 100644 (file)
index 0000000..c68ce04
--- /dev/null
@@ -0,0 +1,19 @@
+class Orvos::V1::SchemaController < ApplicationController
+  skip_before_filter :find_object_by_uuid
+  def show
+    Rails.application.eager_load!
+    classes = {}
+    ActiveRecord::Base.descendants.each do |k|
+      classes[k] = k.columns.collect do |col|
+        if k.serialized_attributes.has_key? col.name
+          { name: col.name,
+            type: k.serialized_attributes[col.name].object_class.to_s }
+        else
+          { name: col.name,
+            type: col.type }
+        end
+      end
+    end
+    render json: classes
+  end
+end
index 7e1dbe90c3fd63685f9bb12b9da271f3276fbde6..8acc5bb6f532850e8fa4c4ad22a84e3a7271ac33 100644 (file)
@@ -70,6 +70,7 @@ Server::Application.routes.draw do
       resources :pipelines
       resources :pipeline_invocations
       resources :pipelineInvocations
+      match '/schema' => 'schema#show'
       match '/nodes/:uuid/ping' => 'nodes#ping', :as => :ping_node
       match '/metadata/:target_kind/:target_uuid' => 'metadata#index'
     end