The metaid.rb file came straight from why the lucky stiff's "seeing
metaclasses clearly" article.  Rails used this too, but they recently
deprecated the name metaclass in favor of singleton_class to match what
ruby-core decided to do.  meta, eigen and singlton class were all
suggested and in the end singleton was agreed upon.

http://redmine.ruby-lang.org/issues/show/1082

Signed-off-by: Matt Robinson <[email protected]>
---
 lib/puppet/metatype/manager.rb                     |    4 ++--
 lib/puppet/network/xmlrpc/client.rb                |    2 +-
 lib/puppet/parameter.rb                            |    4 ++--
 lib/puppet/provider.rb                             |    2 +-
 .../provider/nameservice/directoryservice.rb       |    2 +-
 lib/puppet/util/metaid.rb                          |    8 ++++----
 spec/unit/file_serving/content.rb                  |    2 +-
 spec/unit/file_serving/metadata.rb                 |    2 +-
 spec/unit/indirector.rb                            |    2 +-
 spec/unit/indirector/indirection.rb                |    2 +-
 spec/unit/indirector/yaml.rb                       |    2 +-
 spec/unit/relationship.rb                          |    2 +-
 spec/unit/resource.rb                              |    2 +-
 spec/unit/resource/catalog.rb                      |    2 +-
 spec/unit/ssl/certificate.rb                       |    2 +-
 spec/unit/ssl/certificate_request.rb               |    2 +-
 spec/unit/ssl/key.rb                               |    2 +-
 spec/unit/util/cacher.rb                           |    4 ++--
 spec/unit/util/tagging.rb                          |    2 +-
 test/language/scope.rb                             |    2 +-
 test/network/server/mongrel_test.rb                |    2 +-
 21 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/lib/puppet/metatype/manager.rb b/lib/puppet/metatype/manager.rb
index 865a7c2..34b2bde 100644
--- a/lib/puppet/metatype/manager.rb
+++ b/lib/puppet/metatype/manager.rb
@@ -42,7 +42,7 @@ module Manager
         newmethod = "new#{name.to_s}"
 
         # Used for method manipulation.
-        selfobj = metaclass()
+        selfobj = singleton_class()
 
         @types ||= {}
 
@@ -103,7 +103,7 @@ module Manager
         )
 
         if respond_to?("new" + name.to_s)
-            metaclass.send(:remove_method, "new" + name.to_s)
+            singleton_class.send(:remove_method, "new" + name.to_s)
         end
     end
 
diff --git a/lib/puppet/network/xmlrpc/client.rb 
b/lib/puppet/network/xmlrpc/client.rb
index 9faa71c..f12d279 100644
--- a/lib/puppet/network/xmlrpc/client.rb
+++ b/lib/puppet/network/xmlrpc/client.rb
@@ -49,7 +49,7 @@ module Puppet::Network
 
         class ErrorHandler
             def initialize(&block)
-                metaclass.define_method(:execute, &block)
+                singleton_class.define_method(:execute, &block)
             end
         end
 
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb
index 58a9147..2ebb740 100644
--- a/lib/puppet/parameter.rb
+++ b/lib/puppet/parameter.rb
@@ -296,8 +296,8 @@ class Puppet::Parameter
         # Optionaly convert the value to a canonical form so that it will
         # be found in hashes, etc.  Mostly useful for namevars.
         def to_canonicalize(&block)
-            metaclass = (class << self; self; end)
-            metaclass.send(:define_method,:canonicalize,&block)
+            singleton_class = (class << self; self; end)
+            singleton_class.send(:define_method,:canonicalize,&block)
         end
 
         # Mark whether we're the namevar.
diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb
index 3cef0dd..2627926 100644
--- a/lib/puppet/provider.rb
+++ b/lib/puppet/provider.rb
@@ -109,7 +109,7 @@ class Puppet::Provider
     # Create the methods for a given command.
     def self.make_command_methods(name)
         # Now define a method for that command
-        unless metaclass.method_defined? name
+        unless singleton_class.method_defined? name
             meta_def(name) do |*args|
                 unless command(name)
                     raise Puppet::Error, "Command %s is missing" % name
diff --git a/lib/puppet/provider/nameservice/directoryservice.rb 
b/lib/puppet/provider/nameservice/directoryservice.rb
index 50c87fe..9a4424d 100644
--- a/lib/puppet/provider/nameservice/directoryservice.rb
+++ b/lib/puppet/provider/nameservice/directoryservice.rb
@@ -20,7 +20,7 @@ require 'cgi'
 
 class Puppet::Provider::NameService
 class DirectoryService < Puppet::Provider::NameService
-    # JJM: Dive into the eigenclass
+    # JJM: Dive into the singleton_class
     class << self
         # JJM: This allows us to pass information when calling
         #      Puppet::Type.type
diff --git a/lib/puppet/util/metaid.rb b/lib/puppet/util/metaid.rb
index 0c38a5b..076775c 100644
--- a/lib/puppet/util/metaid.rb
+++ b/lib/puppet/util/metaid.rb
@@ -1,14 +1,14 @@
 class Object
     # The hidden singleton lurks behind everyone
-    def metaclass; class << self; self; end; end
-    def meta_eval(&blk); metaclass.instance_eval(&blk); end
+    def singleton_class; class << self; self; end; end
+    def meta_eval(&blk); singleton_class.instance_eval(&blk); end
 
-    # Adds methods to a metaclass
+    # Adds methods to a singleton_class
     def meta_def(name, &blk)
         meta_eval { define_method name, &blk }
     end
 
-    # Remove metaclass methods.
+    # Remove singleton_class methods.
     def meta_undef(name, &blk)
         meta_eval { remove_method name }
     end
diff --git a/spec/unit/file_serving/content.rb 
b/spec/unit/file_serving/content.rb
index eacaff8..111886d 100755
--- a/spec/unit/file_serving/content.rb
+++ b/spec/unit/file_serving/content.rb
@@ -14,7 +14,7 @@ describe Puppet::FileServing::Content do
     end
 
     it "should should include the IndirectionHooks module in its indirection" 
do
-        
Puppet::FileServing::Content.indirection.metaclass.included_modules.should 
include(Puppet::FileServing::IndirectionHooks)
+        
Puppet::FileServing::Content.indirection.singleton_class.included_modules.should
 include(Puppet::FileServing::IndirectionHooks)
     end
 
     it "should only support the raw format" do
diff --git a/spec/unit/file_serving/metadata.rb 
b/spec/unit/file_serving/metadata.rb
index 22f033d..ef2b3b6 100755
--- a/spec/unit/file_serving/metadata.rb
+++ b/spec/unit/file_serving/metadata.rb
@@ -14,7 +14,7 @@ describe Puppet::FileServing::Metadata do
     end
 
     it "should should include the IndirectionHooks module in its indirection" 
do
-        
Puppet::FileServing::Metadata.indirection.metaclass.included_modules.should 
include(Puppet::FileServing::IndirectionHooks)
+        
Puppet::FileServing::Metadata.indirection.singleton_class.included_modules.should
 include(Puppet::FileServing::IndirectionHooks)
     end
 
     it "should have a method that triggers attribute collection" do
diff --git a/spec/unit/indirector.rb b/spec/unit/indirector.rb
index 0b4c616..64f7c42 100755
--- a/spec/unit/indirector.rb
+++ b/spec/unit/indirector.rb
@@ -56,7 +56,7 @@ describe Puppet::Indirector, "when registering an 
indirection" do
 
     it "should extend the class with the Format Handler" do
         @indirection = @thingie.indirects :first
-        @thingie.metaclass.ancestors.should 
be_include(Puppet::Network::FormatHandler)
+        @thingie.singleton_class.ancestors.should 
be_include(Puppet::Network::FormatHandler)
     end
 
     after do
diff --git a/spec/unit/indirector/indirection.rb 
b/spec/unit/indirector/indirection.rb
index 311cc53..2ed51d7 100755
--- a/spec/unit/indirector/indirection.rb
+++ b/spec/unit/indirector/indirection.rb
@@ -133,7 +133,7 @@ describe Puppet::Indirector::Indirection do
         it "should extend itself with any specified module" do
             mod = Module.new
             @indirection = Puppet::Indirector::Indirection.new(mock('model'), 
:test, :extend => mod)
-            @indirection.metaclass.included_modules.should include(mod)
+            @indirection.singleton_class.included_modules.should include(mod)
         end
 
         after do
diff --git a/spec/unit/indirector/yaml.rb b/spec/unit/indirector/yaml.rb
index 7536fbc..0e70708 100755
--- a/spec/unit/indirector/yaml.rb
+++ b/spec/unit/indirector/yaml.rb
@@ -16,7 +16,7 @@ describe Puppet::Indirector::Yaml, " when choosing file 
location" do
         @store = @store_class.new
 
         @subject = Object.new
-        @subject.metaclass.send(:attr_accessor, :name)
+        @subject.singleton_class.send(:attr_accessor, :name)
         @subject.name = :me
 
         @dir = "/what/ever"
diff --git a/spec/unit/relationship.rb b/spec/unit/relationship.rb
index 5a52cb5..b98e4e2 100755
--- a/spec/unit/relationship.rb
+++ b/spec/unit/relationship.rb
@@ -213,7 +213,7 @@ describe Puppet::Relationship, "when converting from pson" 
do
     end
 
     it "should be extended with the PSON utility module" do
-        Puppet::Relationship.metaclass.ancestors.should 
be_include(Puppet::Util::Pson)
+        Puppet::Relationship.singleton_class.ancestors.should 
be_include(Puppet::Util::Pson)
     end
 
     # LAK:NOTE For all of these tests, we convert back to the edge so we can
diff --git a/spec/unit/resource.rb b/spec/unit/resource.rb
index b26f4f9..66a2b7d 100755
--- a/spec/unit/resource.rb
+++ b/spec/unit/resource.rb
@@ -362,7 +362,7 @@ describe Puppet::Resource do
         end
 
         it "should include the pson util module" do
-            Puppet::Resource.metaclass.ancestors.should 
be_include(Puppet::Util::Pson)
+            Puppet::Resource.singleton_class.ancestors.should 
be_include(Puppet::Util::Pson)
         end
 
         # LAK:NOTE For all of these tests, we convert back to the resource so 
we can
diff --git a/spec/unit/resource/catalog.rb b/spec/unit/resource/catalog.rb
index 7583c01..39ddccd 100755
--- a/spec/unit/resource/catalog.rb
+++ b/spec/unit/resource/catalog.rb
@@ -946,7 +946,7 @@ describe Puppet::Resource::Catalog, "when converting from 
pson" do
     end
 
     it "should be extended with the PSON utility module" do
-        Puppet::Resource::Catalog.metaclass.ancestors.should 
be_include(Puppet::Util::Pson)
+        Puppet::Resource::Catalog.singleton_class.ancestors.should 
be_include(Puppet::Util::Pson)
     end
 
     it "should create it with the provided name" do
diff --git a/spec/unit/ssl/certificate.rb b/spec/unit/ssl/certificate.rb
index 0d48991..6bd7e77 100755
--- a/spec/unit/ssl/certificate.rb
+++ b/spec/unit/ssl/certificate.rb
@@ -14,7 +14,7 @@ describe Puppet::SSL::Certificate do
     end
 
     it "should be extended with the Indirector module" do
-        @class.metaclass.should be_include(Puppet::Indirector)
+        @class.singleton_class.should be_include(Puppet::Indirector)
     end
 
     it "should indirect certificate" do
diff --git a/spec/unit/ssl/certificate_request.rb 
b/spec/unit/ssl/certificate_request.rb
index 85e1d54..fa5986a 100755
--- a/spec/unit/ssl/certificate_request.rb
+++ b/spec/unit/ssl/certificate_request.rb
@@ -11,7 +11,7 @@ describe Puppet::SSL::CertificateRequest do
     end
 
     it "should be extended with the Indirector module" do
-        @class.metaclass.should be_include(Puppet::Indirector)
+        @class.singleton_class.should be_include(Puppet::Indirector)
     end
 
     it "should indirect certificate_request" do
diff --git a/spec/unit/ssl/key.rb b/spec/unit/ssl/key.rb
index b234704..cfeaf79 100755
--- a/spec/unit/ssl/key.rb
+++ b/spec/unit/ssl/key.rb
@@ -10,7 +10,7 @@ describe Puppet::SSL::Key do
     end
 
     it "should be extended with the Indirector module" do
-        @class.metaclass.should be_include(Puppet::Indirector)
+        @class.singleton_class.should be_include(Puppet::Indirector)
     end
 
     it "should indirect key" do
diff --git a/spec/unit/util/cacher.rb b/spec/unit/util/cacher.rb
index 40688bc..eb8515e 100755
--- a/spec/unit/util/cacher.rb
+++ b/spec/unit/util/cacher.rb
@@ -40,7 +40,7 @@ end
 
 describe Puppet::Util::Cacher do
     it "should be extended with the Expirer module" do
-        Puppet::Util::Cacher.metaclass.ancestors.should 
be_include(Puppet::Util::Cacher::Expirer)
+        Puppet::Util::Cacher.singleton_class.ancestors.should 
be_include(Puppet::Util::Cacher::Expirer)
     end
 
     it "should support defining cached attributes" do
@@ -154,7 +154,7 @@ describe Puppet::Util::Cacher do
                 extend Puppet::Util::Cacher
             end
 
-            klass.metaclass.cached_attr(:myattr) { "eh" }
+            klass.singleton_class.cached_attr(:myattr) { "eh" }
             klass.myattr
         end
 
diff --git a/spec/unit/util/tagging.rb b/spec/unit/util/tagging.rb
index 3486f46..04800b3 100755
--- a/spec/unit/util/tagging.rb
+++ b/spec/unit/util/tagging.rb
@@ -66,7 +66,7 @@ describe Puppet::Util::Tagging, "when adding tags" do
     end
 
     it "should provide a method for testing tag validity" do
-        @tagger.metaclass.publicize_methods(:valid_tag?)  { @tagger.should 
be_respond_to(:valid_tag?) }
+        @tagger.singleton_class.publicize_methods(:valid_tag?)  { 
@tagger.should be_respond_to(:valid_tag?) }
     end
 
     it "should add qualified classes as tags" do
diff --git a/test/language/scope.rb b/test/language/scope.rb
index 8b06e0d..d7f37eb 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -424,7 +424,7 @@ Host <<||>>"
         # the right namespaces
         scope = mkscope :parser => parser
 
-        parser.metaclass.send(:attr_accessor, :last)
+        parser.singleton_class.send(:attr_accessor, :last)
 
         methods = [:find_hostclass, :find_definition]
         methods.each do |m|
diff --git a/test/network/server/mongrel_test.rb 
b/test/network/server/mongrel_test.rb
index 54bfb39..4414097 100755
--- a/test/network/server/mongrel_test.rb
+++ b/test/network/server/mongrel_test.rb
@@ -18,7 +18,7 @@ class TestMongrelServer < PuppetTest::TestCase
     # Make sure client info is correctly extracted.
     def test_client_info
         obj = Object.new
-        obj.metaclass.send(:attr_accessor, :params)
+        obj.singleton_class.send(:attr_accessor, :params)
         params = {}
         obj.params = params
 
-- 
1.7.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to