class SuperDiff::ObjectInspection::Nodes::OnlyWhen
Attributes
test[R]
Public Class Methods
method_name()
click to toggle source
# File lib/super_diff/object_inspection/nodes/only_when.rb, line 9 def self.method_name :only_when end
new(tree, test, **options, &block)
click to toggle source
# File lib/super_diff/object_inspection/nodes/only_when.rb, line 13 def initialize(tree, test, **options, &block) @tree = tree @test = test @block = block @options = options end
node_name()
click to toggle source
# File lib/super_diff/object_inspection/nodes/only_when.rb, line 5 def self.node_name :only_when end
Public Instance Methods
render_to_lines(object, type:, indentation_level:)
click to toggle source
# File lib/super_diff/object_inspection/nodes/only_when.rb, line 28 def render_to_lines(object, type:, indentation_level:) if test_passes? render_to_lines_in_subtree( object, type: type, indentation_level: indentation_level, ) else [] end end
render_to_string(object)
click to toggle source
# File lib/super_diff/object_inspection/nodes/only_when.rb, line 20 def render_to_string(object) if test_passes? render_to_string_in_subtree(object) else "" end end
Private Instance Methods
test_passes?()
click to toggle source
# File lib/super_diff/object_inspection/nodes/only_when.rb, line 44 def test_passes? if test.arity == 1 test.call(object) else test.call end end