class SuperDiff::ObjectInspection::Nodes::Inspection

Public Class Methods

method_name() click to toggle source
# File lib/super_diff/object_inspection/nodes/inspection.rb, line 9
def self.method_name
  :add_inspection_of
end
node_name() click to toggle source
# File lib/super_diff/object_inspection/nodes/inspection.rb, line 5
def self.node_name
  :inspection
end

Public Instance Methods

render_to_lines(object, type:, indentation_level:) click to toggle source
# File lib/super_diff/object_inspection/nodes/inspection.rb, line 31
def render_to_lines(object, type:, indentation_level:)
  value =
    if block
      evaluate_block(object)
    else
      immediate_value
    end

  SuperDiff::RecursionGuard.
    guarding_recursion_of(value) do |already_seen|
      if already_seen
        [
          SuperDiff::Line.new(
            type: type,
            indentation_level: indentation_level,
            value: SuperDiff::RecursionGuard::PLACEHOLDER,
          ),
        ]
      else
        SuperDiff.inspect_object(
          value,
          as_lines: true,
          type: type,
          indentation_level: indentation_level,
        )
      end
    end
end
render_to_string(object) click to toggle source
# File lib/super_diff/object_inspection/nodes/inspection.rb, line 13
def render_to_string(object)
  value =
    if block
      evaluate_block(object)
    else
      immediate_value
    end

  SuperDiff::RecursionGuard.
    guarding_recursion_of(value) do |already_seen|
      if already_seen
        SuperDiff::RecursionGuard::PLACEHOLDER
      else
        SuperDiff.inspect_object(value, as_lines: false)
      end
    end
end