Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tiny_singleton

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny_singleton

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

tiny_singleton

  • Homepage
  • Gems
  • Issues
  • Documentation
  • [Email](mailto:Damien.Olivier.Robert+gems at gmail.com)

Description

Tiny Singleton is a very simple implementation of the Singleton Design Pattern. Compared to the Singleton module in the stdlib, one does not need to class 'klass.instance' to get access to the singleton object, one can call 'klass.new' as usual. It is thus easier to add the Singleton Pattern to an existing class without changing the way the code calls it.

Features

Examples

require 'tiny_singleton'

class Foo
  prepend TinySingleton
  def initialize(foo)
    @foo=foo
  end
end

foo=Foo.new("foo")
bar=Foo.new("bar")
foo.object_id == bar.object_id #=> true

Requirements

It needs at least ruby 2.0 since it relies on Module#prepend

Install

$ gem install tiny_singleton

Copyright (c) 2015 Damien Robert

MIT License. See {file:LICENSE.txt} for details.

FAQs

Package last updated on 23 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc