Class: Xavier::States Private

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeStates

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.

Parameters:

  • state (State)

    State representation of an object under observation.

Returns:

  • (States)

    The whole states collection.



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.

Parameters:

  • object_id (Integer)

    The object_id of the observable.

Returns:

  • (Boolean)

    Whether the states collection contains a state representation of an object.



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.

Parameters:

  • state (State)

    State representation of an object under observation.

Returns:

  • (Integer)

    The object_id of the observable.



28
29
30
# File 'lib/xavier/states.rb', line 28

def remove(state)
  collection.delete(state.observed_object_id)
end