From f942ed719a9e71749fc8bbdcddf6cce825046489 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 16 Aug 2015 10:01:12 +0300 Subject: [PATCH] try to get object recursion going --- app/main/controllers/objects_controller.rb | 29 ++++++++++++++++++++++ app/main/views/objects/index.html | 16 ++++++++++++ app/main/views/registers/index.html | 16 +----------- spec/app/main/integration/objects_spec.rb | 5 ++++ 4 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 app/main/controllers/objects_controller.rb create mode 100644 app/main/views/objects/index.html create mode 100644 spec/app/main/integration/objects_spec.rb diff --git a/app/main/controllers/objects_controller.rb b/app/main/controllers/objects_controller.rb new file mode 100644 index 0000000..ea23394 --- /dev/null +++ b/app/main/controllers/objects_controller.rb @@ -0,0 +1,29 @@ +module Main + class ObjectsController < Volt::ModelController + + def marker var + return "Wo" if var.is_a? String + var.class.name.split("::").last[0,2] + end + + def content(id) + object = Virtual.machine.objects[id] + fields = [] + if object and ! object.is_a?(String) + clazz = object.class.name.split("::").last + fields << ["#{clazz}:#{object.internal_object_length}" , 0] + fields << ["--------------------" , 0 ] + object.get_instance_variables.each do |variable| + f = object.get_instance_variable(variable) + fields << ["#{variable} : #{marker(f)} : #{f.object_id}" , f.object_id] + end + end + fields + end + + def is_object?( id ) + Virtual.machine.objects[id] != nil + end + + end +end diff --git a/app/main/views/objects/index.html b/app/main/views/objects/index.html new file mode 100644 index 0000000..b1d640c --- /dev/null +++ b/app/main/views/objects/index.html @@ -0,0 +1,16 @@ +<:Title> + objects index + +<:Body> +
  • + {{attrs.object}} + {{ if(is_object?(attrs.id) and (attrs.level < 4)) }} + + {{ end }} +
  • diff --git a/app/main/views/registers/index.html b/app/main/views/registers/index.html index 226867f..20dfd40 100644 --- a/app/main/views/registers/index.html +++ b/app/main/views/registers/index.html @@ -21,7 +21,7 @@ {{ if is_object?( con[1])}} {{ end }} @@ -35,17 +35,3 @@ {{end}} - -<:Object> -
  • - {{attrs.object}} - {{ if(is_object?(attrs.id) and (attrs.level < 4)) }} - - {{ end }} -
  • diff --git a/spec/app/main/integration/objects_spec.rb b/spec/app/main/integration/objects_spec.rb new file mode 100644 index 0000000..f8c4990 --- /dev/null +++ b/spec/app/main/integration/objects_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe '', type: :feature do + # Specs here +end