Module: RSMP::Inspect

Included in:
Archive, Component, Listener, Message, Node, Notifier, Proxy
Defined in:
lib/rsmp/inspect.rb

Instance Method Summary collapse

Instance Method Details

#inspectObject

override this if you want additional variable to be shown in the short format, or ottherwise change the inspect format


41
42
43
# File 'lib/rsmp/inspect.rb', line 41

def inspect
  "#<#{self.class.name}:#{self.object_id}, #{inspector}>"
end

#inspector(*short_items) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rsmp/inspect.rb', line 16

def inspector *short_items
  instance_variables.map do |var_name|
    var = instance_variable_get(var_name)
    class_name = var.class.name

    short = short_items.include?(var_name) ||
               class_name.start_with?('Async') ||
               class_name.start_with?('RSMP')

    if short
      if var.is_a? Array
        "#{var_name}: #<#{class_name}:#{class_name.object_id}, #{var.size} items>"
      elsif var.is_a? Hash
        "#{var_name}: #<#{class_name}:#{class_name.object_id}, #{var.size} items>"
      else
        "#{var_name}: #{var.to_s}"
      end
    else
      "#{var_name}: #{var.inspect}"
    end
  end.join(', ')
end