Class: Laser::Analysis::LaserSingletonClass
- Inherits:
-
LaserClass
- Object
- LaserObject
- LaserModule
- LaserClass
- Laser::Analysis::LaserSingletonClass
- Defined in:
- lib/laser/analysis/bootstrap/laser_singleton_class.rb
Overview
Singleton classes are important to model separately: they only have one instance! Plus, the built-in classes have some oddities: TrueClass is actually a singleton class, not a normal class. true is its singleton object.
Instance Attribute Summary (collapse)
-
- (Object) singleton_instance
readonly
Returns the value of attribute singleton_instance.
Attributes inherited from LaserClass
Attributes inherited from LaserModule
Attributes inherited from LaserObject
#klass, #name, #scope, #singleton_class
Instance Method Summary (collapse)
- - (Object) get_instance(scope = nil)
-
- (LaserSingletonClass) initialize(klass, scope, path, instance_or_name)
constructor
A new instance of LaserSingletonClass.
Methods inherited from LaserClass
#add_subclass!, #class_name, #inspect, #normal_class, #proper_subset, #proper_superset, #remove_subclass!, #singleton_class, #subset, #superclass, #superclass=, #superset
Methods inherited from LaserModule
#<=>, #===, #__all_instance_methods, #__instance_methods_with_privacy, #__make_module_function__, #__visibility_modifier__, #add_instance_method!, #add_instance_variable!, #alias_method, #ancestors, #as_type, #class_name, #classes_including, #const_defined?, #const_get, #const_set, #define_method, #define_method_with_annotations, #extend, #include, #include_module, #included_modules, #initialize_protocol, #initialize_scope, #inspect, #instance_method, #instance_methods, #instance_variable, #instance_variables, #ivar_type, #method_defined?, #module_function, #name, #name_set?, #parent, #private, #private_instance_methods, #protected, #protected_instance_methods, #protected_method_defined?, #public, #public_instance_method, #public_instance_methods, #remove_const, #remove_method, #set_ivar_type, #set_name, #set_visibility!, #submodule_path, #subset, #undef_method, #validate_module_path!, #visibility_for, #visibility_table
Methods inherited from LaserObject
#add_instance_method!, #inspect, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #laser_simulate, #normal_class
Methods included from ModuleExtensions
#attr_accessor_with_default, #cattr_accessor, #cattr_accessor_with_default, #cattr_get_and_setter, #cattr_reader, #cattr_writer, #opposite_method
Constructor Details
- (LaserSingletonClass) initialize(klass, scope, path, instance_or_name)
A new instance of LaserSingletonClass
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/laser/analysis/bootstrap/laser_singleton_class.rb', line 28 def initialize(klass, scope, path, instance_or_name) super(klass, scope, path) # Dirty hook for the magic singletons: nil, true, false. if String === instance_or_name result = LaserObject.new(self, scope, instance_or_name) result.singleton_class = self @singleton_instance = result else @singleton_instance = instance_or_name end end |
Instance Attribute Details
- (Object) singleton_instance (readonly)
Returns the value of attribute singleton_instance
27 28 29 |
# File 'lib/laser/analysis/bootstrap/laser_singleton_class.rb', line 27 def singleton_instance @singleton_instance end |
Instance Method Details
- (Object) get_instance(scope = nil)
39 40 41 |
# File 'lib/laser/analysis/bootstrap/laser_singleton_class.rb', line 39 def get_instance(scope=nil) singleton_instance end |