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:

  • ?.?.?

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:

  • ?.?.?


19
20
21
# File 'lib/pry/command_state.rb', line 19

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:

  • ?.?.?


15
16
17
# File 'lib/pry/command_state.rb', line 15

def self.default
  @default ||= new
end

Instance Method Details

#reset(command_name) ⇒ 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:

  • ?.?.?


27
28
29
# File 'lib/pry/command_state.rb', line 27

def reset(command_name)
  @command_state[command_name] = OpenStruct.new
end

#state_for(command_name) ⇒ 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:

  • ?.?.?


23
24
25
# File 'lib/pry/command_state.rb', line 23

def state_for(command_name)
  @command_state[command_name] ||= OpenStruct.new
end