Sha256: 87b84d09d7c051dcd2a5ba380fb19a35074ac2f4374014e8fda28c28f02da9da

Contents?: true

Size: 567 Bytes

Versions: 19

Compression:

Stored size: 567 Bytes

Contents

require 'singleton'

module RightSupport::Ruby
  module EasySingleton
    module ClassMethods
      def method_missing(meth, *args)
        if self.instance && self.instance.respond_to?(meth)
          self.instance.__send__(meth, *args)
        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

19 entries across 19 versions & 1 rubygems

Version Path
right_support-2.3.4 lib/right_support/ruby/easy_singleton.rb
right_support-2.3.3 lib/right_support/ruby/easy_singleton.rb
right_support-2.3.2 lib/right_support/ruby/easy_singleton.rb
right_support-2.3.1 lib/right_support/ruby/easy_singleton.rb
right_support-2.3.0 lib/right_support/ruby/easy_singleton.rb
right_support-2.2.2 lib/right_support/ruby/easy_singleton.rb
right_support-2.2.1 lib/right_support/ruby/easy_singleton.rb
right_support-2.2.0 lib/right_support/ruby/easy_singleton.rb
right_support-2.1.0 lib/right_support/ruby/easy_singleton.rb
right_support-1.4.1 lib/right_support/ruby/easy_singleton.rb
right_support-2.0.4 lib/right_support/ruby/easy_singleton.rb
right_support-2.0.3 lib/right_support/ruby/easy_singleton.rb
right_support-1.4.0 lib/right_support/ruby/easy_singleton.rb
right_support-2.0.0 lib/right_support/ruby/easy_singleton.rb
right_support-1.3.3 lib/right_support/ruby/easy_singleton.rb
right_support-1.3.2 lib/right_support/ruby/easy_singleton.rb
right_support-1.3.1 lib/right_support/ruby/easy_singleton.rb
right_support-1.3.0 lib/right_support/ruby/easy_singleton.rb
right_support-1.2.0 lib/right_support/ruby/easy_singleton.rb