Class: Xavier::States Private
- Inherits:
-
Object
- Object
- Xavier::States
- Defined in:
- lib/xavier/states.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.
Collection of state representations of objects under observation.
Instance Method Summary collapse
-
#add(state) ⇒ States
private
Stores the state representation of an object.
-
#contain?(object_id) ⇒ Boolean
private
Returns whether the states collection contains a state representation of an object, using its unique object_id.
-
#initialize ⇒ States
constructor
private
Creates an instance of States.
-
#remove(state) ⇒ Integer
private
Deletes the state representation of an object.
Constructor Details
#initialize ⇒ States
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.
Creates an instance of States.
9 10 11 |
# File 'lib/xavier/states.rb', line 9 def initialize @collection = {} end |
Instance Method Details
#add(state) ⇒ States
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.
Stores the state representation of an object.
18 19 20 21 |
# File 'lib/xavier/states.rb', line 18 def add(state) collection[state.observed_object_id] = state self end |
#contain?(object_id) ⇒ Boolean
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 whether the states collection contains a state representation of an object, using its unique object_id.
37 38 39 |
# File 'lib/xavier/states.rb', line 37 def contain?(object_id) collection.key?(object_id) end |
#remove(state) ⇒ Integer
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.
Deletes the state representation of an object.
28 29 30 |
# File 'lib/xavier/states.rb', line 28 def remove(state) collection.delete(state.observed_object_id) end |