call_super 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Call Super #
2
+
3
+ http://rubygems.org/gems/call_super
4
+
5
+ # Summary #
6
+
7
+ Add calls to super in fundamental Object methods so modules can be used to include/extend.
8
+
9
+ # Description #
10
+
11
+ Cause Object#inherited, Module#extended, Module#extend_object, Module#included, Module#append_features to call super if defined.
12
+
13
+ # Install #
14
+
15
+ * sudo gem install call_super
16
+
17
+ # Usage #
18
+
19
+ ```ruby
20
+ Class.extend( SomeModuleDefining#inherited )
21
+ Class.include( SomeModuleDefining#inherited )
22
+
23
+ Module.include( SomeModuleDefining#append_features )
24
+ Module.include( SomeModuleDefining#included )
25
+ Module.include( SomeModuleDefining#extend_object )
26
+ Module.include( SomeModuleDefining#extended )
27
+
28
+ module.extend( SomeModuleDefining#append_features )
29
+ module.extend( SomeModuleDefining#included )
30
+ module.extend( SomeModuleDefining#extend_object )
31
+ module.extend( SomeModuleDefining#extended )
32
+ ```
33
+
34
+ # License #
35
+
36
+ (The MIT License)
37
+
38
+ Copyright (c) 2013 Ridiculous Power, Asher
39
+
40
+ Permission is hereby granted, free of charge, to any person obtaining
41
+ a copy of this software and associated documentation files (the
42
+ 'Software'), to deal in the Software without restriction, including
43
+ without limitation the rights to use, copy, modify, merge, publish,
44
+ distribute, sublicense, and/or sell copies of the Software, and to
45
+ permit persons to whom the Software is furnished to do so, subject to
46
+ the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be
49
+ included in all copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
52
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
53
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
54
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
55
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
56
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
57
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/lib/call_super.rb ADDED
@@ -0,0 +1,10 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ ###
4
+ # Cause Object#inherited, Module#extended, Module#extend_object, Module#included,
5
+ # Module#append_features to call super if defined.
6
+ #
7
+ # Features have to be implemented in Class and Module directly; see lib_ext for implementation.
8
+ #
9
+ module ::CallSuper
10
+ end
data/lib_ext/class.rb ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class ::Class
4
+
5
+ include ::CallSuper
6
+
7
+ ###############
8
+ # inherited #
9
+ ###############
10
+
11
+ ###
12
+ # Override Class.inherited so that modules extending Class can define #inherited.
13
+ #
14
+ def inherited( hooked_instance )
15
+
16
+ super if defined?( super )
17
+
18
+ end
19
+
20
+ end
data/lib_ext/module.rb ADDED
@@ -0,0 +1,73 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ class ::Module
4
+
5
+ include ::CallSuper
6
+
7
+ ##############################
8
+ # original_append_features #
9
+ ##############################
10
+
11
+ alias_method :original_append_features, :append_features
12
+
13
+ #####################
14
+ # append_features #
15
+ #####################
16
+
17
+ ###
18
+ # Override Module.included so that modules extending Module can define #included.
19
+ #
20
+ def append_features( hooked_instance )
21
+
22
+ original_append_features( hooked_instance )
23
+ super if defined?( super )
24
+
25
+ end
26
+
27
+ ##############
28
+ # included #
29
+ ##############
30
+
31
+ ###
32
+ # Override Module.included so that modules extending Module can define #included.
33
+ #
34
+ def included( hooked_instance )
35
+
36
+ super if defined?( super )
37
+
38
+ end
39
+
40
+ ############################
41
+ # original_extend_object #
42
+ ############################
43
+
44
+ alias_method :original_extend_object, :extend_object
45
+
46
+ ###################
47
+ # extend_object #
48
+ ###################
49
+
50
+ ###
51
+ # Override Module.extended so that modules extending Module can define #extended.
52
+ #
53
+ def extend_object( hooked_instance )
54
+
55
+ original_extend_object( hooked_instance )
56
+ super if defined?( super )
57
+
58
+ end
59
+
60
+ ##############
61
+ # extended #
62
+ ##############
63
+
64
+ ###
65
+ # Override Module.extended so that modules extending Module can define #extended.
66
+ #
67
+ def extended( hooked_instance )
68
+
69
+ super if defined?( super )
70
+
71
+ end
72
+
73
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: call_super
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Asher
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-08 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Cause Object#inherited, Module#extended, Module#extend_object, Module#included,
15
+ Module#append_features to call super if defined.
16
+ email: asher@ridiculouspower.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/call_super.rb
22
+ - lib_ext/class.rb
23
+ - lib_ext/module.rb
24
+ - README.md
25
+ - CHANGELOG.md
26
+ homepage: http://rubygems.org/gems/call_super
27
+ licenses: []
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.9.1
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project: call_super
46
+ rubygems_version: 1.8.23
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: Add calls to super in fundamental Object methods so modules can be used to
50
+ include/extend.
51
+ test_files: []