refinement_builder 1.0.4 → 1.0.5
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.
- checksums.yaml +4 -4
- data/README.md +9 -8
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b1afc5db20e67a31004c14df6c7d46fa513ec3e
|
4
|
+
data.tar.gz: b17aa0341839cc1303d5ccb2192e0cb828944efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 558d64403438f94d150a1b1405779746d931002899f69a9a4bbe06837cb197e1d0cabac6c90dd3f6eb212e152385fdb19d3120f60f3868efcad58baa0ade7d74
|
7
|
+
data.tar.gz: 7e6f3cbb1b5a79244b046416f93a72651fee68b6e538d6fb3f723bee3c0265d90f1446578c5dba4caa802011316d2c6c468deacd8c5b3fbca79e0a3f74d6173d
|
data/README.md
CHANGED
@@ -76,14 +76,6 @@ The `StringPatch` has its methods accessible in the same 3 ways as `RefinementBu
|
|
76
76
|
"hello world".print_first_5_characters
|
77
77
|
# => hello
|
78
78
|
|
79
|
-
## Under the hood
|
80
|
-
Under the hood, what happens is this:
|
81
|
-
|
82
|
-
1. A module is defined with the given name and instance method definitions
|
83
|
-
2. Each of the instance methods is overwritten in such a way that it will delegate to the class method if called from any other scope, and execute the original function body if it's in class method scope.
|
84
|
-
3. The instance methods are copied to class methods via `module_function`
|
85
|
-
3. A refinement is defined with the instance methods.
|
86
|
-
|
87
79
|
## Usage 4 - _options_
|
88
80
|
|
89
81
|
`refinement_builder` only cares about three arguments (and the block):
|
@@ -94,6 +86,15 @@ Under the hood, what happens is this:
|
|
94
86
|
1. `namespace: <class/module>` where the module will be created under (defaults to Object)
|
95
87
|
2. `refines: <class>` what the refinement will patch. Also defaults to Object.
|
96
88
|
|
89
|
+
## Under the hood
|
90
|
+
Under the hood, what happens is this:
|
91
|
+
|
92
|
+
1. A module is defined with the given name and instance method definitions
|
93
|
+
2. Each of the instance methods is overwritten in such a way that it will delegate to the class method if called from any other scope, and execute the original function body if it's in class method scope.
|
94
|
+
3. The instance methods are copied to class methods via `module_function`
|
95
|
+
3. A refinement is defined with the instance methods.
|
96
|
+
|
97
|
+
|
97
98
|
## Benefits of this approach
|
98
99
|
|
99
100
|
The main benefit is the ability to get these multiple usages without writing wrapper functions. Here's a module definition which is about the same as the one created by this factory:
|
data/lib/version.rb
CHANGED