Sha256: af611a06243a946b225c0e3651a4555b8c45adb816fcd0dd6c45684e99a04d84

Contents?: true

Size: 583 Bytes

Versions: 23

Compression:

Stored size: 583 Bytes

Contents

require 'singleton'

module RightSupport::Ruby
  module EasySingleton
    module ClassMethods
      def method_missing(meth, *args, &block)
        if self.instance && self.instance.respond_to?(meth)
          self.instance.__send__(meth, *args, &block)
        else
          super
        end
      end

      def respond_to?(meth)
        super(meth) || self.instance.respond_to?(meth)
      end
    end

    def self.included(base)
      base.__send__(:include, ::Singleton) unless base.ancestors.include?(::Singleton)
      base.__send__(:extend, ClassMethods)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
right_support-2.6.17 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.16 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.15 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.12 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.11 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.10 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.9 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.8 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.7 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.5 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.4 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.3 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.2 lib/right_support/ruby/easy_singleton.rb
right_support-2.6.1 lib/right_support/ruby/easy_singleton.rb
right_support-2.5.5 lib/right_support/ruby/easy_singleton.rb
right_support-2.5.4 lib/right_support/ruby/easy_singleton.rb
right_support-2.5.2 lib/right_support/ruby/easy_singleton.rb
right_support-2.5.1 lib/right_support/ruby/easy_singleton.rb
right_support-2.5.0 lib/right_support/ruby/easy_singleton.rb
right_support-2.4.1 lib/right_support/ruby/easy_singleton.rb