Exception: MustBe::ContainerNote

Inherits:
Note show all
Extended by:
Forwardable
Defined in:
lib/must_be/containers.rb

Direct Known Subclasses

PairNote

Instance Attribute Summary collapse

Attributes inherited from Note

#additional_message, #args, #assertion, #block, #prefix, #receiver

Instance Method Summary collapse

Methods inherited from Note

#complete_backtrace

Constructor Details

#initialize(original_note, container = nil) ⇒ ContainerNote

Returns a new instance of ContainerNote.



17
18
19
20
# File 'lib/must_be/containers.rb', line 17

def initialize(original_note, container = nil)
  @original_note = original_note
  @container = container
end

Instance Attribute Details

#containerObject

Returns the value of attribute container.



7
8
9
# File 'lib/must_be/containers.rb', line 7

def container
  @container
end

#original_noteObject

Returns the value of attribute original_note.



7
8
9
# File 'lib/must_be/containers.rb', line 7

def original_note
  @original_note
end

Instance Method Details

#backtraceObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/must_be/containers.rb', line 32

def backtrace
  return unless regular_backtrace
  
  if container.respond_to?(:must_only_ever_contain_backtrace) and
      container.must_only_ever_contain_backtrace
    regular_backtrace+["=== caused by container ==="]+
      container.must_only_ever_contain_backtrace
  else
    regular_backtrace
  end
end

#regular_backtraceObject



30
# File 'lib/must_be/containers.rb', line 30

alias regular_backtrace backtrace

#to_sObject



22
23
24
25
26
27
28
# File 'lib/must_be/containers.rb', line 22

def to_s
  if assertion
    @original_note.to_s+" in container #{MustBe.short_inspect(container)}"
  else
    @original_note.to_s
  end
end