Class: Pry::CommandState Private

Inherits:
Object show all
Defined in:
lib/pry/command_state.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

CommandState is a data structure to hold per-command state.

Pry commands can store arbitrary state here. This state persists between subsequent command invocations. All state saved here is unique to the command.

Since:

  • v0.13.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandState

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CommandState.

Since:

  • v0.13.0



17
18
19
# File 'lib/pry/command_state.rb', line 17

def initialize
  @command_state = {}
end

Class Method Details

.defaultObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v0.13.0



13
14
15
# File 'lib/pry/command_state.rb', line 13

def self.default
  @default ||= new
end

Instance Method Details

#reset(command_class) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v0.13.0



25
26
27
# File 'lib/pry/command_state.rb', line 25

def reset(command_class)
  @command_state[command_class] = command_struct(command_class)
end

#state_for(command_class) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • v0.13.0



21
22
23
# File 'lib/pry/command_state.rb', line 21

def state_for(command_class)
  @command_state[command_class] ||= command_struct(command_class)
end