Module: VimMate::NiceSingleton
- Included in:
- Config, Icons, Subversion
- Defined in:
- lib/vim_mate/nice_singleton.rb
Overview
A nicer singleton implementation. When a class mixes this module, it becomes a singleton and you don’t have to use ‘instance’ to access the singleton’s class method. For example:
class Hello
include VimMate::NiceSingleton
def hello
"hello"
end
end
Hello.hello # => "hello"
Class Method Summary collapse
Class Method Details
.included(other) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vim_mate/nice_singleton.rb', line 42 def self.included(other) if other.class == Class other.send(:include, Singleton) class << other def method_missing(method, *args, &block) self.instance.send(method, *args) end end end end |