mixin 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +9 -9
- data/lib/mixin.rb +1 -1
- metadata +11 -11
data/README
CHANGED
@@ -7,7 +7,7 @@ when it comes to defining class methods.
|
|
7
7
|
Typically, the way to implement a mixin that defines class methods for its
|
8
8
|
includees (at least that I have noticed) is to define a module within the mixin
|
9
9
|
module, usually called +ClassMethods+, which gets automatically extended to an
|
10
|
-
including class by overwriting the mixin's +
|
10
|
+
including class by overwriting the mixin's +included+ method. This technique
|
11
11
|
is usually sufficient for most situations, but it has a few limitations. One of
|
12
12
|
these is the fact that class attributes referenced in +ClassMethods+ do not
|
13
13
|
exist in the same scope as the enclosing mixin's class attributes.
|
@@ -16,17 +16,17 @@ exist in the same scope as the enclosing mixin's class attributes.
|
|
16
16
|
|
17
17
|
Mixin comes in handy in following situations:
|
18
18
|
|
19
|
-
* When you are writing a mixin with class methods that need to access class
|
20
|
-
attributes defined within the mixin module.
|
19
|
+
* When you are writing a mixin with class methods that need to access <b>class
|
20
|
+
attributes</b> defined within the mixin module.
|
21
21
|
|
22
22
|
* When you want to define a "sub-mixin" module which includes another mixin
|
23
|
-
in order to expand upon its class methods in addition to its instance methods
|
24
|
-
|
25
|
-
|
23
|
+
in order to expand upon its class methods in addition to its instance methods.
|
24
|
+
This includes <b>calls to +super+</b> to invoke a "super-mixin's" implementation
|
25
|
+
of a given class method.
|
26
26
|
|
27
|
-
* When you simply get tired of writing the same old "<tt>def self.
|
28
|
-
base.extend(ClassMethods)</tt>" method (or some variation of it) over and over
|
29
|
-
again
|
27
|
+
* When you simply <b>get tired of writing</b> the same old <b>"<tt>def self.included(base);
|
28
|
+
base.extend(ClassMethods)</tt>"</b> method (or some variation of it) <b>over and over
|
29
|
+
again</b>, thereby violating the sacred DRY principle ;)
|
30
30
|
|
31
31
|
== Examples
|
32
32
|
|
data/lib/mixin.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hersch Stevenson (xian)
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-10 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: Mixins made classier
|
22
|
+
description: Mixins made classier
|
23
23
|
email: stevenson@persapient.com
|
24
24
|
executables: []
|
25
25
|
|
@@ -30,17 +30,17 @@ extra_rdoc_files:
|
|
30
30
|
- LICENSE
|
31
31
|
files:
|
32
32
|
- lib/mixin.rb
|
33
|
-
- test/
|
34
|
-
- test/test_subjects/
|
33
|
+
- test/test_subjects/scopers.rb
|
34
|
+
- test/test_subjects/meepers.rb
|
35
35
|
- test/test_subjects/extenders.rb
|
36
|
+
- test/test_subjects/sleepers.rb
|
37
|
+
- test/test_subjects/clevers.rb
|
36
38
|
- test/test_subjects/hopons.rb
|
37
|
-
- test/test_subjects/includers.rb
|
38
|
-
- test/test_subjects/meepers.rb
|
39
39
|
- test/test_subjects/nudgers.rb
|
40
|
-
- test/test_subjects/
|
41
|
-
- test/test_subjects/sleepers.rb
|
40
|
+
- test/test_subjects/includers.rb
|
42
41
|
- test/test_subjects/soopers.rb
|
43
42
|
- test/test_subjects/weirdos.rb
|
43
|
+
- test/mixin_case.rb
|
44
44
|
- README
|
45
45
|
- LICENSE
|
46
46
|
- Rakefile
|