Class: PryExceptionExplorer::Intercept

Inherits:
Object
  • Object
show all
Defined in:
lib/pry-exception_explorer/intercept.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Intercept) initialize(block)

Returns a new instance of Intercept



60
61
62
63
64
65
66
# File 'lib/pry-exception_explorer/intercept.rb', line 60

def initialize(block)
  skip(0)
  intercept_recurse(false)

  @block  = block
  @active = true
end

Instance Attribute Details

- (Proc) block (readonly)

Returns The predicate block that determines if interception takes place.

Returns:

  • (Proc)

    The predicate block that determines if interception takes place.



6
7
8
# File 'lib/pry-exception_explorer/intercept.rb', line 6

def block
  @block
end

- (Fixnum) skip_num (readonly)

Returns Number of frames to skip when session starts.

Returns:

  • (Fixnum)

    Number of frames to skip when session starts.



9
10
11
# File 'lib/pry-exception_explorer/intercept.rb', line 9

def skip_num
  @skip_num
end

- (Proc) skip_until_block (readonly)

Returns The block that determines when to stop skipping frames.

Returns:

  • (Proc)

    The block that determines when to stop skipping frames.



15
16
17
# File 'lib/pry-exception_explorer/intercept.rb', line 15

def skip_until_block
  @skip_until_block
end

- (Proc) skip_while_block (readonly)

Returns The block that defines the frames to skip.

Returns:

  • (Proc)

    The block that defines the frames to skip.



12
13
14
# File 'lib/pry-exception_explorer/intercept.rb', line 12

def skip_while_block
  @skip_while_block
end

Instance Method Details

- (Boolean) active?

Returns Whether this intercept object is active If it's inactive then calling it will always return false regardless of content inside block.

Returns:

  • (Boolean)

    Whether this intercept object is active If it's inactive then calling it will always return false regardless of content inside block.



20
# File 'lib/pry-exception_explorer/intercept.rb', line 20

def active?() !!@active end

- (Boolean) call(*args)

Invoke the associated block for this PryExceptionExplorer::Intercept object. Note that the block is not invoked if the intercept object is inactive.

Parameters:

  • args (Array)

    The parameters to

Returns:

  • (Boolean)

    Determines whether a given exception should be intercepted.



73
74
75
# File 'lib/pry-exception_explorer/intercept.rb', line 73

def call(*args)
  active? && @block.call(*args)
end

- (PryExceptionExplorer::Intercept) disable!

Disable the intercept object.

Returns:



24
# File 'lib/pry-exception_explorer/intercept.rb', line 24

def disable!() tap { @active = false } end

- (PryExceptionExplorer::Intercept) enable!

Enable if the intercept object.

Returns:



28
# File 'lib/pry-exception_explorer/intercept.rb', line 28

def enable!() tap { @active = true } end

- (PryExceptionExplorer::Intercept) intercept_recurse(should_recurse)

Returns The receiver

Parameters:

  • should_recurse (Boolean)

    Whether to intercept exceptions raised inside the session.

Returns:



54
# File 'lib/pry-exception_explorer/intercept.rb', line 54

def intercept_recurse(should_recurse) tap { @intercept_recurse = should_recurse } end

- (Boolean) intercept_recurse?

Returns Whether exceptions raised inside the session will be intercepted.

Returns:

  • (Boolean)

    Whether exceptions raised inside the session will be intercepted.



58
# File 'lib/pry-exception_explorer/intercept.rb', line 58

def intercept_recurse?() !!@intercept_recurse end

- (PryExceptionExplorer::Intercept) skip(num)

Returns The receiver

Parameters:

  • num (Fixnum)

    Number of frames to skip when session starts.

Returns:



33
# File 'lib/pry-exception_explorer/intercept.rb', line 33

def skip(num) tap { @skip_num = num } end

- (PryExceptionExplorer::Intercept) skip_until {|lazy_frame| ... }

Returns The receiver

Yields:

  • (lazy_frame)

    The block that determines when to stop skipping frames. The Pry session will start on the first frame for which this block evalutes to true.

Yield Parameters:

Yield Returns:

  • (Boolean)

Returns:



49
# File 'lib/pry-exception_explorer/intercept.rb', line 49

def skip_until(&block) tap { @skip_until_block = block } end

- (PryExceptionExplorer::Intercept) skip_while {|lazy_frame| ... }

Returns The receiver

Yields:

  • (lazy_frame)

    The block that defines the frames to skip. The Pry session will start on the first frame for which this block evalutes to false.

Yield Parameters:

Yield Returns:

  • (Boolean)

Returns:



41
# File 'lib/pry-exception_explorer/intercept.rb', line 41

def skip_while(&block) tap { @skip_while_block = block } end