Class: Pry::CommandState Private
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.
Class Method Summary collapse
- .default ⇒ Object private
Instance Method Summary collapse
-
#initialize ⇒ CommandState
constructor
private
A new instance of CommandState.
- #reset(command_class) ⇒ Object private
- #state_for(command_class) ⇒ Object private
Constructor Details
#initialize ⇒ CommandState
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.
17 18 19 |
# File 'lib/pry/command_state.rb', line 17 def initialize @command_state = {} end |
Class Method Details
.default ⇒ 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.
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.
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.
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 |