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

#initialize(block) ⇒ Intercept

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

#blockProc (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

#skip_numFixnum (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

#skip_until_blockProc (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

#skip_while_blockProc (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

#active?Boolean

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

#call(*args) ⇒ Boolean

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

#disable!PryExceptionExplorer::Intercept

Disable the intercept object.

Returns:



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

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

#enable!PryExceptionExplorer::Intercept

Enable if the intercept object.

Returns:



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

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

#intercept_recurse(should_recurse) ⇒ PryExceptionExplorer::Intercept

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

#intercept_recurse?Boolean

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

#skip(num) ⇒ PryExceptionExplorer::Intercept

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

#skip_until {|lazy_frame| ... } ⇒ PryExceptionExplorer::Intercept

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

#skip_while {|lazy_frame| ... } ⇒ PryExceptionExplorer::Intercept

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