Sha256: b6b4826bde36499efe8bfe35788aa9821ac8c32c902c813a6a59ee944ce8c9bf

Contents?: true

Size: 580 Bytes

Versions: 6

Compression:

Stored size: 580 Bytes

Contents

# Singleton methods are defined here so zombie can pick them up
module Mutant

  # Define instance of subclassed superclass as constant
  #
  # @param [Class] superclass
  # @param [Symbol] name
  #
  # @return [self]
  #
  # @api private
  #
  def self.define_singleton_subclass(name, superclass, &block)
    klass = Class.new(superclass) do

      def inspect; self.class.name; end

      define_singleton_method(:name) do
        "#{superclass.name}::#{name}".freeze
      end

    end
    klass.class_eval(&block)
    superclass.const_set(name, klass.new)
    self
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.2.20 lib/mutant/singleton_methods.rb
mutant-0.2.17 lib/mutant/singleton_methods.rb
mutant-0.2.16 lib/mutant/singleton_methods.rb
mutant-0.2.15 lib/mutant/singleton_methods.rb
mutant-0.2.14 lib/mutant/singleton_methods.rb
mutant-0.2.13 lib/mutant/singleton_methods.rb