metaclass-0.0.4/0000755000004100000410000000000012303073572013521 5ustar www-datawww-datametaclass-0.0.4/Rakefile0000644000004100000410000000030112303073572015160 0ustar www-datawww-datarequire 'bundler/gem_tasks' require "rake/testtask" Rake::TestTask.new do |t| t.libs << "test" t.test_files = FileList["test/**/*_test.rb"] t.verbose = true end task :default => :test metaclass-0.0.4/Gemfile0000644000004100000410000000004612303073572015014 0ustar www-datawww-datasource "http://rubygems.org" gemspec metaclass-0.0.4/COPYING.txt0000644000004100000410000000205712303073572015376 0ustar www-datawww-data== Licence (MIT) Copyright (c) 2011 James Mead Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.metaclass-0.0.4/lib/0000755000004100000410000000000012303073572014267 5ustar www-datawww-datametaclass-0.0.4/lib/metaclass/0000755000004100000410000000000012303073572016243 5ustar www-datawww-datametaclass-0.0.4/lib/metaclass/object_methods.rb0000644000004100000410000000022712303073572021562 0ustar www-datawww-datamodule Metaclass::ObjectMethods def __metaclass__ class << self self end end end class Object include Metaclass::ObjectMethods endmetaclass-0.0.4/lib/metaclass/version.rb0000644000004100000410000000005112303073572020251 0ustar www-datawww-datamodule Metaclass VERSION = "0.0.4" end metaclass-0.0.4/lib/metaclass.rb0000644000004100000410000000012512303073572016566 0ustar www-datawww-datamodule Metaclass end require "metaclass/version" require "metaclass/object_methods" metaclass-0.0.4/metadata.yml0000644000004100000410000000224012303073572016022 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: metaclass version: !ruby/object:Gem::Version version: 0.0.4 platform: ruby authors: - James Mead autorequire: bindir: bin cert_chain: [] date: 2014-02-20 00:00:00.000000000 Z dependencies: [] description: email: - james@floehopper.org executables: [] extensions: [] extra_rdoc_files: [] files: - .gitignore - COPYING.txt - Gemfile - README.md - Rakefile - lib/metaclass.rb - lib/metaclass/object_methods.rb - lib/metaclass/version.rb - metaclass.gemspec - test/object_methods_test.rb - test/test_helper.rb homepage: http://github.com/floehopper/metaclass licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: metaclass rubygems_version: 2.0.14 signing_key: specification_version: 4 summary: Adds a metaclass method to all Ruby objects test_files: - test/object_methods_test.rb - test/test_helper.rb metaclass-0.0.4/test/0000755000004100000410000000000012303073572014500 5ustar www-datawww-datametaclass-0.0.4/test/test_helper.rb0000644000004100000410000000012412303073572017340 0ustar www-datawww-datarequire "rubygems" require "bundler/setup" require "metaclass" require "test/unit" metaclass-0.0.4/test/object_methods_test.rb0000644000004100000410000000144112303073572021055 0ustar www-datawww-datarequire "test_helper" class ObjectMethodsTest < Test::Unit::TestCase def setup @klass = Class.new end def test_define_method_on_only_one_instance_of_a_class instance = @klass.new assert_raises(NoMethodError) { instance.success? } instance.__metaclass__.class_eval { def success?; true; end } assert_nothing_raised(NoMethodError) { assert instance.success? } another_instance = @klass.new assert_raises(NoMethodError) { another_instance.success? } end def test_metaclass_ancestors instance = @klass.new assert instance.__metaclass__.ancestors.include?(Object) assert instance.__metaclass__.ancestors.include?(Kernel) end def test_metaclass_is_itself_a_class instance = @klass.new assert instance.__metaclass__.is_a?(Class) end endmetaclass-0.0.4/.gitignore0000644000004100000410000000004112303073572015504 0ustar www-datawww-data*.gem .bundle Gemfile.lock pkg/* metaclass-0.0.4/metaclass.gemspec0000644000004100000410000000126712303073572017050 0ustar www-datawww-data# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "metaclass/version" Gem::Specification.new do |s| s.name = "metaclass" s.version = Metaclass::VERSION s.authors = ["James Mead"] s.email = ["james@floehopper.org"] s.homepage = "http://github.com/floehopper/metaclass" s.summary = %q{Adds a metaclass method to all Ruby objects} s.license = "MIT" s.rubyforge_project = "metaclass" s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] endmetaclass-0.0.4/checksums.yaml.gz0000444000004100000410000000041612303073572017010 0ustar www-datawww-data‹;ìSe=R@…ûœ"ˆ³À. éìì=¿V6N*OïÆRg¨€ïñx·Ûíòþö ÷ËõúYK{ØËÇ÷ýºzemtM4Yä» ª@lU…²våž…‡ûeöõËÉ „pë]³‰Ã&­áäjdŠ•Ï« ðßÝÝ~dL›{¶0£Î”©Ýš¶Aœªœm/ƒ’ã0uˆªÏS›Î4ÆÙ•UÑÉd!ûÂ"çœkìV LÕ†ÈTÐPÕ¥ÁEÿÉÐåÑ€Q%˜,{D9¶Ëi „Po 0f§E\æ³úUœÈÔM=à¤I €s×:æ‡Àæ~¦3 7Î'±¦B%ã év¤@ºü”)”¢metaclass-0.0.4/README.md0000644000004100000410000000124412303073572015001 0ustar www-datawww-dataAdds a `__metaclass__` method to all Ruby objects. ## Motivations * Even though WhyTheLuckyStiff's [metaid gem](https://rubygems.org/gems/metaid) does something similar, apparently the metaclass method without underscores [doesn't play well with Rails v2.3](https://github.com/floehopper/mocha/commit/f0749d6d291164cc9280aa8ba16f33d652d45fe1#commitcomment-475799). * I'm trying to extract code out of the [mocha gem](https://github.com/floehopper/mocha) and this is an obvious candidate. ## License This library is released under the [MIT License](http://www.opensource.org/licenses/MIT). See [COPYING.txt](https://github.com/floehopper/metaclass/blob/master/COPYING.txt).