lib/app/controllers/triplify_controller.rb in rtriplify-0.0.2 vs lib/app/controllers/triplify_controller.rb in rtriplify-0.0.3

- old
+ new

@@ -1,7 +1,7 @@ require 'configatron' - +# class TriplifyController < ActionController::Base def tripleize t = Tripleizer.new t.base_uri = t.uri request.env['REQUEST_URI'].to_s @@ -59,38 +59,41 @@ end #get all models def model t, model_group models = t.find_models model_group - models.values[0].each do |model_name, model_attributes| - if model_name.to_s =="sql_query" - t.write_sql(model_group_name,model_attributes,output) - else - t.write_model(model_name, models.keys[0]) + if models + models.values[0].each do |model_name, model_attributes| + if model_name.to_s =="sql_query" + t.write_sql(models.keys[0],model_attributes,output) + else + t.write_model(model_name, models.keys[0]) + end end end end # get a defined model with given id def index t,param subclass,id = param models = t.find_models subclass - models.values[0].each do |model_name, model_attributes| - if model_name.to_s =="sql_query" - #some magic is needed here ..parse the sql query? - else - m = Model.new model_name, models.keys[0].to_s - row_values=m.get_row_by_id(id).first - c1=Hash.new - if row_values - m.model.columns_hash.each_with_index do |column_name,i| - c1[column_name[0]]=eval("row_values.#{column_name}") + if models + models.values[0].each do |model_name, model_attributes| + if model_name.to_s =="sql_query" + #some magic is needed here ..parse the sql query? + else + m = Model.new model_name, models.keys[0].to_s + row_values=m.get_row_by_id(id).first + c1=Hash.new + if row_values + m.model.columns_hash.each_with_index do |column_name,i| + c1[column_name[0]]=eval("row_values.#{column_name}") + end + t.extract_id_line model_attributes, c1,row_values,m.get_datatypes + t.make_triples(c1, models.keys[0].to_s , "", m.get_datatypes) end - t.extract_id_line model_attributes, c1,row_values,m.get_datatypes - t.make_triples(c1, models.keys[0].to_s , "", m.get_datatypes) end end - end #render :text => t.make_triples(c1, controller , "", t.dbd_types) end end