Linux server1.dn-server.com 4.18.0-553.89.1.lve.el8.x86_64 #1 SMP Wed Dec 10 13:58:50 UTC 2025 x86_64
LiteSpeed
Server IP : 195.201.204.189 & Your IP : 216.73.216.37
Domains :
Cant Read [ /etc/named.conf ]
User : beriska1
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
opt /
alt /
ruby22 /
share /
ri /
2.2.0 /
system /
Singleton /
Delete
Unzip
Name
Size
Permission
Date
Action
_dump-i.ri
335
B
-rw-r--r--
2023-07-26 18:01
_load-c.ri
337
B
-rw-r--r--
2023-07-26 18:01
append_features-c.ri
259
B
-rw-r--r--
2023-07-26 18:01
cdesc-Singleton.ri
3.3
KB
-rw-r--r--
2023-07-26 18:01
clone-i.ri
310
B
-rw-r--r--
2023-07-26 18:01
dup-i.ri
305
B
-rw-r--r--
2023-07-26 18:01
included-c.ri
247
B
-rw-r--r--
2023-07-26 18:01
Save
Rename
U:RDoc::NormalModule[iI"Singleton:EF@0o:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[I";The Singleton module implements the Singleton pattern.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading: leveli: textI" Usage;T@o; ;[I"8To use Singleton, include the module in your class.;T@o:RDoc::Markup::Verbatim;[ I"class Klass ;TI" include Singleton ;TI" # ... ;TI" end ;T:@format0o; ;[I"AThis ensures that only one instance of Klass can be created.;T@o;;[I"+a,b = Klass.instance, Klass.instance ;TI" ;TI"a == b ;TI"# => true ;TI" ;TI"Klass.new ;TI"-# => NoMethodError - new is private ... ;T;0o; ;[I"HThe instance is created at upon the first call of Klass.instance().;T@o;;[I"class OtherKlass ;TI" include Singleton ;TI" # ... ;TI" end ;TI" ;TI"+ObjectSpace.each_object(OtherKlass){} ;TI"# => 0 ;TI" ;TI"OtherKlass.instance ;TI"+ObjectSpace.each_object(OtherKlass){} ;TI"# => 1 ;T;0o; ;[I">This behavior is preserved under inheritance and cloning.;T@S;;i; I"Implementation;T@o; ;[I"This above is achieved by:;T@o:RDoc::Markup::List: @type:BULLET:@items[ o:RDoc::Markup::ListItem:@label0;[o; ;[I"1Making Klass.new and Klass.allocate private.;T@o;;0;[o; ;[I"POverriding Klass.inherited(sub_klass) and Klass.clone() to ensure that the ;TI"=Singleton properties are kept when inherited and cloned.;T@o;;0;[o; ;[I"MProviding the Klass.instance() method that returns the same object each ;TI"time it is called.;T@o;;0;[o; ;[I":Overriding Klass._load(str) to call Klass.instance().;T@o;;0;[o; ;[I"IOverriding Klass#clone and Klass#dup to raise TypeErrors to prevent ;TI"cloning or duping.;T@S;;i; I"Singleton and Marshal;T@o; ;[ I"SBy default Singleton's #_dump(depth) returns the empty string. Marshalling by ;TI"Mdefault will strip state information, e.g. instance variables and taint ;TI"Jstate, from the instance. Classes using Singleton can provide custom ;TI"Q_load(str) and _dump(depth) methods to retain some of the previous state of ;TI"the instance.;T@o;;["I"require 'singleton' ;TI" ;TI"class Example ;TI" include Singleton ;TI"# attr_accessor :keep, :strip ;TI" def _dump(depth) ;TI"@ # this strips the @strip information from the instance ;TI"$ Marshal.dump(@keep, depth) ;TI" end ;TI" ;TI" def self._load(str) ;TI"+ instance.keep = Marshal.load(str) ;TI" instance ;TI" end ;TI" end ;TI" ;TI"a = Example.instance ;TI"a.keep = "keep this" ;TI"!a.strip = "get rid of this" ;TI" a.taint ;TI" ;TI"$stored_state = Marshal.dump(a) ;TI" ;TI"a.keep = nil ;TI"a.strip = nil ;TI"$b = Marshal.load(stored_state) ;TI"p a == b # => true ;TI"!p a.keep # => "keep this" ;TI"p a.strip # => nil;T;0: @fileI"lib/singleton.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[ [ [ [[I" class;T[[:public[[I" _load;TI"lib/singleton.rb;T[:protected[ [:private[[I"append_features;F@�[I" included;F@�[I" instance;T[[;[[I" _dump;F@�[I" clone;F@�[I"dup;F@�[;[ [;[ [[I"SingletonClassMethods;To;;[ ;@�;0@�[U:RDoc::Context::Section[i 0o;;[ ;0;0[@�@�cRDoc::TopLevel