Module: Singleton::ClassMethods
- Defined in:
- lib/sup/util.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *a, &b) ⇒ Object
511
512
513
514
515
516
517
518
519
520
521
|
# File 'lib/sup/util.rb', line 511
def method_missing meth, *a, &b
raise "no #{name} instance defined in method call to #{meth}!" unless defined? @instance
return nil if @instance.nil?
@instance.send meth, *a, &b
end
|
Instance Method Details
#deinstantiate! ⇒ Object
510
|
# File 'lib/sup/util.rb', line 510
def deinstantiate!; @instance = nil; end
|
#init(*args) ⇒ Object
522
523
524
525
|
# File 'lib/sup/util.rb', line 522
def init *args
raise "there can be only one! (instance)" if defined? @instance
@instance = new(*args)
end
|
508
|
# File 'lib/sup/util.rb', line 508
def instance; @instance; end
|
#instantiated? ⇒ Boolean
509
|
# File 'lib/sup/util.rb', line 509
def instantiated?; defined?(@instance) && !@instance.nil?; end
|