GRAYBYTE WORDPRESS FILE MANAGER4172

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /opt/alt/ruby30/share/ruby/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/alt/ruby30/share/ruby//singleton.rb
# frozen_string_literal: false

# The Singleton module implements the Singleton pattern.
#
# == Usage
#
# To use Singleton, include the module in your class.
#
#    class Klass
#       include Singleton
#       # ...
#    end
#
# This ensures that only one instance of Klass can be created.
#
#      a,b = Klass.instance, Klass.instance
#
#      a == b
#      # => true
#
#      Klass.new
#      # => NoMethodError - new is private ...
#
# The instance is created at upon the first call of Klass.instance().
#
#      class OtherKlass
#        include Singleton
#        # ...
#      end
#
#      ObjectSpace.each_object(OtherKlass){}
#      # => 0
#
#      OtherKlass.instance
#      ObjectSpace.each_object(OtherKlass){}
#      # => 1
#
#
# This behavior is preserved under inheritance and cloning.
#
# == Implementation
#
# This above is achieved by:
#
# *  Making Klass.new and Klass.allocate private.
#
# *  Overriding Klass.inherited(sub_klass) and Klass.clone() to ensure that the
#    Singleton properties are kept when inherited and cloned.
#
# *  Providing the Klass.instance() method that returns the same object each
#    time it is called.
#
# *  Overriding Klass._load(str) to call Klass.instance().
#
# *  Overriding Klass#clone and Klass#dup to raise TypeErrors to prevent
#    cloning or duping.
#
# == Singleton and Marshal
#
# By default Singleton's #_dump(depth) returns the empty string. Marshalling by
# default will strip state information, e.g. instance variables from the instance.
# Classes using Singleton can provide custom _load(str) and _dump(depth) methods
# to retain some of the previous state of the instance.
#
#    require 'singleton'
#
#    class Example
#      include Singleton
#      attr_accessor :keep, :strip
#      def _dump(depth)
#        # this strips the @strip information from the instance
#        Marshal.dump(@keep, depth)
#      end
#
#      def self._load(str)
#        instance.keep = Marshal.load(str)
#        instance
#      end
#    end
#
#    a = Example.instance
#    a.keep = "keep this"
#    a.strip = "get rid of this"
#
#    stored_state = Marshal.dump(a)
#
#    a.keep = nil
#    a.strip = nil
#    b = Marshal.load(stored_state)
#    p a == b  #  => true
#    p a.keep  #  => "keep this"
#    p a.strip #  => nil
#
module Singleton
  VERSION = "0.1.1"

  # Raises a TypeError to prevent cloning.
  def clone
    raise TypeError, "can't clone instance of singleton #{self.class}"
  end

  # Raises a TypeError to prevent duping.
  def dup
    raise TypeError, "can't dup instance of singleton #{self.class}"
  end

  # By default, do not retain any state when marshalling.
  def _dump(depth = -1)
    ''
  end

  module SingletonClassMethods # :nodoc:

    def clone # :nodoc:
      Singleton.__init__(super)
    end

    # By default calls instance(). Override to retain singleton state.
    def _load(str)
      instance
    end

    def instance # :nodoc:
      return @singleton__instance__ if @singleton__instance__
      @singleton__mutex__.synchronize {
        return @singleton__instance__ if @singleton__instance__
        @singleton__instance__ = new()
      }
      @singleton__instance__
    end

    private

    def inherited(sub_klass)
      super
      Singleton.__init__(sub_klass)
    end
  end

  class << Singleton # :nodoc:
    def __init__(klass) # :nodoc:
      klass.instance_eval {
        @singleton__instance__ = nil
        @singleton__mutex__ = Thread::Mutex.new
      }
      klass
    end

    private

    # extending an object with Singleton is a bad idea
    undef_method :extend_object

    def append_features(mod)
      #  help out people counting on transitive mixins
      unless mod.instance_of?(Class)
        raise TypeError, "Inclusion of the OO-Singleton module in module #{mod}"
      end
      super
    end

    def included(klass)
      super
      klass.private_class_method :new, :allocate
      klass.extend SingletonClassMethods
      Singleton.__init__(klass)
    end
  end

  ##
  # :singleton-method: _load
  #  By default calls instance(). Override to retain singleton state.

  ##
  # :singleton-method: instance
  #  Returns the singleton instance.
end

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
January 01 1970 00:00:00
root / root
0
benchmark
--
July 17 2024 08:38:23
root / linksafe
0755
bigdecimal
--
July 17 2024 08:38:27
root / linksafe
0755
cgi
--
July 17 2024 08:38:23
root / linksafe
0755
csv
--
July 17 2024 08:38:23
root / linksafe
0755
did_you_mean
--
July 17 2024 08:38:23
root / linksafe
0755
digest
--
July 17 2024 08:38:23
root / linksafe
0755
drb
--
July 17 2024 08:38:23
root / linksafe
0755
fiddle
--
July 17 2024 08:38:23
root / linksafe
0755
forwardable
--
July 17 2024 08:38:23
root / linksafe
0755
io
--
June 26 2024 13:55:13
root / linksafe
0755
json
--
July 17 2024 08:38:31
root / linksafe
0755
logger
--
July 17 2024 08:38:23
root / linksafe
0755
matrix
--
July 17 2024 08:38:23
root / linksafe
0755
net
--
July 17 2024 08:38:23
root / linksafe
0755
openssl
--
July 17 2024 08:38:23
root / linksafe
0755
optparse
--
July 17 2024 08:38:23
root / linksafe
0755
psych
--
July 17 2024 08:38:31
root / linksafe
0755
racc
--
July 17 2024 08:38:23
root / linksafe
0755
reline
--
July 17 2024 08:38:23
root / linksafe
0755
rinda
--
July 17 2024 08:38:23
root / linksafe
0755
ripper
--
July 17 2024 08:38:23
root / linksafe
0755
set
--
July 17 2024 08:38:23
root / linksafe
0755
syslog
--
July 17 2024 08:38:23
root / linksafe
0755
unicode_normalize
--
July 17 2024 08:38:23
root / linksafe
0755
uri
--
July 17 2024 08:38:23
root / linksafe
0755
vendor_ruby
--
June 26 2024 13:55:13
root / linksafe
0755
yaml
--
July 17 2024 08:38:23
root / linksafe
0755
English.rb
6.111 KB
June 26 2024 13:55:18
root / linksafe
0644
abbrev.rb
3.446 KB
June 26 2024 13:55:18
root / linksafe
0644
base64.rb
3.3 KB
June 26 2024 13:55:18
root / linksafe
0644
benchmark.rb
18.021 KB
June 26 2024 13:55:18
root / linksafe
0644
bigdecimal.rb
0.023 KB
June 26 2024 13:55:18
root / linksafe
0644
cgi.rb
9.821 KB
June 26 2024 13:55:18
root / linksafe
0644
coverage.rb
0.359 KB
June 26 2024 13:55:18
root / linksafe
0644
csv.rb
86.712 KB
June 26 2024 13:55:18
root / linksafe
0644
date.rb
1.018 KB
June 26 2024 13:55:18
root / linksafe
0644
debug.rb
30.305 KB
June 26 2024 13:55:18
root / linksafe
0644
delegate.rb
11.681 KB
June 26 2024 13:55:17
root / linksafe
0644
did_you_mean.rb
3.854 KB
June 26 2024 13:55:17
root / linksafe
0644
digest.rb
2.826 KB
June 26 2024 13:55:18
root / linksafe
0644
drb.rb
0.049 KB
June 26 2024 13:55:18
root / linksafe
0644
erb.rb
28.813 KB
June 26 2024 13:55:18
root / linksafe
0644
expect.rb
2.165 KB
June 26 2024 13:55:17
root / linksafe
0644
fiddle.rb
2.111 KB
June 26 2024 13:55:18
root / linksafe
0644
fileutils.rb
48.258 KB
June 26 2024 13:55:17
root / linksafe
0644
find.rb
2.467 KB
June 26 2024 13:55:18
root / linksafe
0644
forwardable.rb
8.976 KB
June 26 2024 13:55:17
root / linksafe
0644
getoptlong.rb
15.45 KB
June 26 2024 13:55:18
root / linksafe
0644
ipaddr.rb
19.521 KB
June 26 2024 13:55:17
root / linksafe
0644
json.rb
19.296 KB
June 26 2024 13:55:18
root / linksafe
0644
kconv.rb
5.724 KB
June 26 2024 13:55:18
root / linksafe
0644
logger.rb
16.484 KB
June 26 2024 13:55:18
root / linksafe
0644
matrix.rb
61.833 KB
June 26 2024 13:55:18
root / linksafe
0644
mkmf.rb
86.586 KB
June 26 2024 13:55:18
root / linksafe
0644
monitor.rb
6.758 KB
June 26 2024 13:55:17
root / linksafe
0644
mutex_m.rb
2.229 KB
June 26 2024 13:55:18
root / linksafe
0644
objspace.rb
2.664 KB
June 26 2024 13:55:18
root / linksafe
0644
observer.rb
6.379 KB
June 26 2024 13:55:18
root / linksafe
0644
open-uri.rb
24.736 KB
June 26 2024 13:55:18
root / linksafe
0644
open3.rb
21.93 KB
June 26 2024 13:55:18
root / linksafe
0644
openssl.rb
1.061 KB
June 26 2024 13:55:18
root / linksafe
0644
optionparser.rb
0.058 KB
June 26 2024 13:55:18
root / linksafe
0644
optparse.rb
60.336 KB
June 26 2024 13:55:17
root / linksafe
0644
ostruct.rb
12.385 KB
June 26 2024 13:55:17
root / linksafe
0644
pathname.rb
16.461 KB
June 26 2024 13:55:18
root / linksafe
0644
pp.rb
15.846 KB
June 26 2024 13:55:18
root / linksafe
0644
prettyprint.rb
15.899 KB
June 26 2024 13:55:18
root / linksafe
0644
prime.rb
15.132 KB
June 26 2024 13:55:18
root / linksafe
0644
pstore.rb
14.73 KB
June 26 2024 13:55:18
root / linksafe
0644
psych.rb
22.399 KB
June 26 2024 13:55:17
root / linksafe
0644
racc.rb
0.134 KB
June 26 2024 13:55:18
root / linksafe
0644
readline.rb
0.11 KB
June 26 2024 13:55:18
root / linksafe
0644
reline.rb
13.897 KB
June 26 2024 13:55:18
root / linksafe
0644
resolv-replace.rb
1.763 KB
June 26 2024 13:55:18
root / linksafe
0644
resolv.rb
74.179 KB
June 26 2024 13:55:18
root / linksafe
0644
ripper.rb
2.436 KB
June 26 2024 13:55:18
root / linksafe
0644
securerandom.rb
8.857 KB
June 26 2024 13:55:17
root / linksafe
0644
set.rb
19.42 KB
June 26 2024 13:55:18
root / linksafe
0644
shellwords.rb
7.089 KB
June 26 2024 13:55:18
root / linksafe
0644
singleton.rb
4.08 KB
June 26 2024 13:55:18
root / linksafe
0644
socket.rb
43.654 KB
June 26 2024 13:55:18
root / linksafe
0644
tempfile.rb
12.43 KB
June 26 2024 13:55:18
root / linksafe
0644
time.rb
24.27 KB
June 26 2024 13:55:18
root / linksafe
0644
timeout.rb
4 KB
June 26 2024 13:55:18
root / linksafe
0644
tmpdir.rb
4.396 KB
June 26 2024 13:55:18
root / linksafe
0644
tracer.rb
6.504 KB
June 26 2024 13:55:17
root / linksafe
0644
tsort.rb
14.299 KB
June 26 2024 13:55:18
root / linksafe
0644
un.rb
10.114 KB
June 26 2024 13:55:18
root / linksafe
0644
uri.rb
3.038 KB
June 26 2024 13:55:18
root / linksafe
0644
weakref.rb
1.458 KB
June 26 2024 13:55:18
root / linksafe
0644
yaml.rb
1.798 KB
June 26 2024 13:55:18
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF