Class: Naught::NullClassBuilder::Commands::Singleton

Inherits:
Naught::NullClassBuilder::Command show all
Defined in:
lib/naught/null_class_builder/commands/singleton.rb

Instance Attribute Summary

Attributes inherited from Naught::NullClassBuilder::Command

#builder

Instance Method Summary collapse

Methods inherited from Naught::NullClassBuilder::Command

#defer, #initialize

Constructor Details

This class inherits a constructor from Naught::NullClassBuilder::Command

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/naught/null_class_builder/commands/singleton.rb', line 7

def call
  defer(:class => true) do |subject|
    require 'singleton'
    subject.module_eval do
      include ::Singleton

      def self.get(*)
        instance
      end

      %w(dup clone).each do |method_name|
        define_method method_name do
          self
        end
      end
    end
  end
end