Class: Object

Inherits:
BasicObject
Defined in:
lib/mdbe/database_views/object.rb

Instance Method Summary collapse

Instance Method Details

#__basetypeObject



2
3
4
# File 'lib/mdbe/database_views/object.rb', line 2

def __basetype
  :object
end

#__evaluate_smalltalk(code) ⇒ Object



63
64
65
# File 'lib/mdbe/database_views/object.rb', line 63

def __evaluate_smalltalk(code)
  code.__evaluate_smalltalk_in_context(self)
end

#custom_database_tabsObject



6
7
8
9
# File 'lib/mdbe/database_views/object.rb', line 6

def custom_database_tabs
  # [["Demo Tab", "demoData", "html with: 'This is an example'."]]
  []
end

#to_database_view(orig_depth, ranges = {}, params = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/mdbe/database_views/object.rb', line 11

def to_database_view(orig_depth, ranges = {}, params = {})
  obj = {:oop => self.object_id}

  depth = param_modify_depth(orig_depth, ranges, params)

  if depth > 0
    obj[:loaded] = true
    obj[:exception] = false
    obj[:classObject] = self.class.to_database_view(depth - 1, {}, params)
    obj[:virtualClassObject] = self.__virtual_class.to_database_view(depth - 1, {}, params)   # singleton class

    obj[:instVars] = {}
    obj[:instVarsSize] = 0

    if depth == 2
      obj[:customTabs] = self.custom_database_tabs
    else
      obj[:customTabs] = []
    end

    if render_inst_vars
      index = 1
      range_from = ranges[:instVars] ? Integer(ranges[:instVars][0]) : 1
      range_to = ranges[:instVars] ? Integer(ranges[:instVars][1]) : 10

      obj[:instVarsSize] = self.instance_variables.size

      ((range_from - 1)..[range_to - 1, self.instance_variables.size - 1].min).each do |index|
        begin
          obj[:instVars][index + 1] = [self.instance_variables[index].to_database_view(depth - 1, {}, params), self.instance_variable_get(self.instance_variables[index]).to_database_view(depth - 1, {}, params)]
        rescue Exception => e
          obj[:instVars][index + 1] = [self.instance_variables[index].to_database_view(depth - 1, {}, params), "(error)".to_database_view(1, {}, params)]
        end
      end
    end
  else
    obj[:loaded] = false
  end

  inspection = self.inspect
  if inspection._isString
    obj[:inspection] = inspection[0, 200]
    obj[:inspection] += "..." if obj[:inspection].size < inspection.size
  else
    obj[:inspection] = "(error)"
  end

  obj[:basetype] = __basetype

  return obj
end