public
Rubygem
Description: Ruby module that upon requirement will allow any object to become "abstract" by calling a single method
Homepage: http://www.bjeanes.com/
Clone URL: git://github.com/bjeanes/make_abstract.git
Search Repo:
Click here to lend your support to: make_abstract and make a donation at www.pledgie.com !
First code commit. Created a gemspec but no idea if it's correct as I've 
never created a gem before. Guess we'll find out...
bjeanes (author)
Thu May 15 16:41:54 -0700 2008
commit  555f5e2d7ee5614c36bb61f7b28faf95b18f624e
tree    1804e92e613cb48765b4f9e995bf9dcfe98d7b6e
parent  7c91522b1c6eaaa10f0829db1e40c9c448d00300
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -1 +1,18 @@
0
+module MakeAbstract
0
+
0
+ # http://www.shaneharvie.com/2007/08/making-constructors-protected-in-ruby.html
0
+ def self.included(klass)
0
+ klass.module_eval do
0
+ class << self
0
+ protected :new
0
+
0
+ def inherited(klass)
0
+ klass.module_eval do
0
+ def self.new(*args); super; end
0
+ end
0
+ end
0
+ end
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
0
@@ -1 +1,14 @@
0
+Gem::Specification.new do |s|
0
+ s.name = "make_abstract"
0
+ s.version = "0.0.1"
0
+ s.date = "2008-05-15"
0
+ s.summary = "Fake abstract classes in ruby with ease"
0
+ s.email = "me@bjeanes.com"
0
+ s.homepage = "http://github.com/bjeanes/make_abstract"
0
+ s.description = "make_abstract is a Ruby module that allows you to create an abstract class by calling a single method."
0
+ s.has_rdoc = false
0
+ s.authors = ["Bodaniel Jeanes"]
0
+ s.files = ["README.markdown", "make_abstract.rb", "lib/make_abstract.rb"]
0
+ s.test_files = ["test/test_make_abstract.rb", "test_classes.rb"]
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
0
@@ -1 +1,12 @@
0
+require 'lib/make_abstract'
0
+
0
+class Object
0
+ class << self
0
+ def make_abstract
0
+ self.class_eval do
0
+ include MakeAbstract
0
+ end
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
0
@@ -1 +1,11 @@
0
+class AbstractClass
0
+ make_abstract
0
+end
0
+
0
+class ChildClass < AbstractClass
0
+end
0
+
0
+class AbstractChildClass < AbstractClass
0
+ make_abstract
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
0
@@ -1 +1,30 @@
0
+require 'test/unit'
0
+require 'make_abstract'
0
+require 'test/test_classes'
0
+
0
+class TestMakeAbstract < Test::Unit::TestCase
0
+ def test_defines_method
0
+ assert_respond_to(AbstractClass, :make_abstract)
0
+ assert_respond_to(String, :make_abstract)
0
+ assert_respond_to(Object, :make_abstract)
0
+ end
0
+
0
+ def test_instantiating_abstract_class_raises_error
0
+ assert_raise NoMethodError do
0
+ AbstractClass.new
0
+ end
0
+ end
0
+
0
+ def test_instantiating_abstract_child_class_raises_error
0
+ assert_raise NoMethodError do
0
+ AbstractChildClass.new
0
+ end
0
+ end
0
+
0
+ def test_instantiating_child_of_abstract_class_doesnt_raise_error
0
+ assert_nothing_raised do
0
+ ChildClass.new
0
+ end
0
+ end
0
+end

Comments

    No one has commented yet.