functionable 1.3.0 → 1.4.0
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
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +36 -0
- data/functionable.gemspec +1 -1
- data/lib/functionable.rb +5 -0
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38972d9fbf56181773cd2ce7d6e10829107e322942cb3e7571d028873421a219
|
|
4
|
+
data.tar.gz: 5efc599a108df041cb2639b17d63d0bd5496abd31a4462fa2e95d5f95100c9a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ce666d66656a9b320c35f2471950a34ad3c175b703dd7c25ce5d61010470ee83195c95c6fdbb399d4cf468de111e5946c4f00e5977e2c3572982b73f6160efa
|
|
7
|
+
data.tar.gz: 881ea1739d912f10cf772c791fd86703e52e1992146b29c82835181c8d888f5dbd7e807263b1ac57fee65ed7663d1603213f64a2637745eca017ec3ec78e9ddf
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/README.adoc
CHANGED
|
@@ -80,6 +80,42 @@ Math.divide 6, 3 # 2
|
|
|
80
80
|
|
|
81
81
|
That's it! Now you can add related methods, as desired, which are specific to your namespace.
|
|
82
82
|
|
|
83
|
+
=== Function Methods
|
|
84
|
+
|
|
85
|
+
You can acquire the array of function method names that were implemented and created by you. By default, you'll get an empty array when no methods are defined:
|
|
86
|
+
|
|
87
|
+
[source,ruby]
|
|
88
|
+
----
|
|
89
|
+
module Demo
|
|
90
|
+
extend Functionable
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
Demo.function_methods # []
|
|
94
|
+
----
|
|
95
|
+
|
|
96
|
+
Once methods are defined, you'll then get an array of names:
|
|
97
|
+
|
|
98
|
+
[source,ruby]
|
|
99
|
+
----
|
|
100
|
+
module Demo
|
|
101
|
+
extend Functionable
|
|
102
|
+
|
|
103
|
+
def one = 1
|
|
104
|
+
|
|
105
|
+
def two = 2
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
Demo.function_methods # [:one, :two]
|
|
109
|
+
----
|
|
110
|
+
|
|
111
|
+
This behavior is similar to what a `Module` already provides you when it comes to categorizing method names:
|
|
112
|
+
|
|
113
|
+
* `Module#instance_methods`
|
|
114
|
+
* `Module#private_instance_methods`
|
|
115
|
+
* `Module#protected_instance_methods`
|
|
116
|
+
* `Module#public_instance_methods`
|
|
117
|
+
* `Module#undefined_instance_methods`
|
|
118
|
+
|
|
83
119
|
=== Conceal
|
|
84
120
|
|
|
85
121
|
Should you need to make any of your methods private, use the `conceal` method as follows:
|
data/functionable.gemspec
CHANGED
data/lib/functionable.rb
CHANGED
|
@@ -20,6 +20,10 @@ module Functionable
|
|
|
20
20
|
|
|
21
21
|
def private(*) = fail NoMethodError, "Private visibility is disabled, use conceal instead."
|
|
22
22
|
|
|
23
|
+
def function_methods
|
|
24
|
+
@function_methods ||= []
|
|
25
|
+
end
|
|
26
|
+
|
|
23
27
|
def conceal(*) = private_class_method(*)
|
|
24
28
|
|
|
25
29
|
def alias_method to, from
|
|
@@ -59,6 +63,7 @@ module Functionable
|
|
|
59
63
|
def method_added name
|
|
60
64
|
unbound = instance_method name
|
|
61
65
|
|
|
66
|
+
function_methods.append name
|
|
62
67
|
instance_variable_set :@functionable, true
|
|
63
68
|
remove_method name
|
|
64
69
|
define_singleton_method name, unbound
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: functionable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brooke Kuhlmann
|
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
73
|
version: '0'
|
|
74
74
|
requirements: []
|
|
75
|
-
rubygems_version: 4.0.
|
|
75
|
+
rubygems_version: 4.0.20
|
|
76
76
|
specification_version: 4
|
|
77
77
|
summary: Enhances modules to be functional by default.
|
|
78
78
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|