Class: Xavier::State Private
- Inherits:
- BasicObject
- Defined in:
- lib/xavier/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.
A storage for an observed class or object’s internal state.
Instance Attribute Summary collapse
-
#observed_object_id ⇒ Integer
readonly
private
Returns the object id of the observed object.
Instance Method Summary collapse
-
#class ⇒ State
private
Returns the class
State
. -
#class_variable_get(name) ⇒ Object
private
Returns the value of the given class variable, or nil if the class variable is not set.
-
#class_variable_set(name, value) ⇒ Object
private
Sets the class variable named by
name
to the given object. -
#class_variables ⇒ Array<Symbol>
private
Returns an array of the names of class variables in mod.
-
#initialize(observed_object_id) ⇒ State
constructor
private
Creates a new state representation.
-
#instance_variable_get(name) ⇒ Object
private
Returns the value of the given instance variable, or
nil
if the instance variable is not set. -
#instance_variable_set(name, value) ⇒ Object
private
Sets the instance variable named by
name
to the given object. -
#instance_variables ⇒ Array<Symbol>
private
Returns an array of instance variable names for the receiver.
-
#is_a?(clazz) ⇒ Boolean
private
Returns true if class is the class of
self
, or ifclazz
is one of the superclasses ofself
or modules.
Constructor Details
#initialize(observed_object_id) ⇒ State
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 a new state representation.
15 16 17 18 19 |
# File 'lib/xavier/state.rb', line 15 def initialize(observed_object_id) @observed_object_id = observed_object_id @class_variables = {} @instance_variables = {} end |
Instance Attribute Details
#observed_object_id ⇒ Integer (readonly)
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 the object id of the observed object
10 11 12 |
# File 'lib/xavier/state.rb', line 10 def observed_object_id @observed_object_id end |
Instance Method Details
#class ⇒ State
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 the class State
.
70 71 72 |
# File 'lib/xavier/state.rb', line 70 def class State end |
#class_variable_get(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.
Returns the value of the given class variable, or nil if the class variable is not set.
55 56 57 |
# File 'lib/xavier/state.rb', line 55 def class_variable_get(name) @class_variables[name.to_sym] end |
#class_variable_set(name, value) ⇒ 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.
Sets the class variable named by name
to the given object.
46 47 48 |
# File 'lib/xavier/state.rb', line 46 def class_variable_set(name, value) @class_variables[name.to_sym] = value end |
#class_variables ⇒ Array<Symbol>
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 an array of the names of class variables in mod.
84 85 86 |
# File 'lib/xavier/state.rb', line 84 def class_variables @class_variables.keys end |
#instance_variable_get(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.
Returns the value of the given instance variable, or nil
if the instance variable is not set.
36 37 38 |
# File 'lib/xavier/state.rb', line 36 def instance_variable_get(name) @instance_variables[name.to_sym] end |
#instance_variable_set(name, value) ⇒ 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.
Sets the instance variable named by name
to the given object.
27 28 29 |
# File 'lib/xavier/state.rb', line 27 def instance_variable_set(name, value) @instance_variables[name.to_sym] = value end |
#instance_variables ⇒ Array<Symbol>
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 an array of instance variable names for the receiver.
77 78 79 |
# File 'lib/xavier/state.rb', line 77 def instance_variables @instance_variables.keys end |
#is_a?(clazz) ⇒ 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 true if class is the class of self
, or if clazz
is one of the superclasses of self
or modules.
62 63 64 65 |
# File 'lib/xavier/state.rb', line 62 def is_a?(clazz) return true if clazz == ::Class self.class == clazz end |