reflection_utils 0.1.0 → 0.2.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
- data/README.md +2 -0
- data/lib/reflection_utils.rb +14 -0
- data/lib/reflection_utils/create_class_methods_upon_include.rb +9 -0
- data/lib/reflection_utils/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb3c338cb45479816001814af0976ffcfe096316
|
4
|
+
data.tar.gz: c5c24aa8cb57aade4ab2816159e444198640bdfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 297d48cb2dc98642267381b0348a3e469365f9ec7c9b06225f3b9f321aa14f0ae7b61772369ad368bd374f757aa2b59a1fe7bafd5715579daf447c37acb1987a
|
7
|
+
data.tar.gz: d371f1aa379e945012f8d94849de533abd22745a3954993c68ab62a13ebcbab67fe1536f67e144ea6b1e683f86edd3fe00fa4a3423c4d4c09fd3adbe2e5370f2
|
data/README.md
CHANGED
@@ -16,6 +16,8 @@ Functions include:
|
|
16
16
|
- has_parameter?(proc, parameter_index, parameter)
|
17
17
|
- has_parameters?(proc, parameters)
|
18
18
|
- assert_parameters(proc, parameters)
|
19
|
+
- non_default_methods(class_or_instance)
|
20
|
+
- module CreateClassMethodsUponInclude (more: http://lifeinacubicleblog.com/2017/06/26/ruby-how-to-use-self-included-meaningfully)
|
19
21
|
|
20
22
|
For usage and examples for each of them take a look at the [unit tests](https://github.com/thisismydesign/reflection_utils/blob/master/spec/reflection_utils_spec.rb).
|
21
23
|
|
data/lib/reflection_utils.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative 'reflection_utils/create_class_methods_upon_include'
|
2
|
+
|
1
3
|
module ReflectionUtils
|
2
4
|
|
3
5
|
def self.get_bound_instance_method(instance:, method_name:)
|
@@ -32,4 +34,16 @@ module ReflectionUtils
|
|
32
34
|
proc.parameters[parameter_index] == parameter
|
33
35
|
end
|
34
36
|
|
37
|
+
def self.non_default_methods(class_or_instance)
|
38
|
+
class_or_instance.is_a?(Module) ? non_default_class_methods(class_or_instance) : non_default_instance_methods(class_or_instance)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.non_default_class_methods(clazz)
|
42
|
+
clazz.methods - Object.methods
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.non_default_instance_methods(instance)
|
46
|
+
instance.methods - Object.new.methods
|
47
|
+
end
|
48
|
+
|
35
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reflection_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thisismydesign
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- bin/console
|
84
84
|
- bin/setup
|
85
85
|
- lib/reflection_utils.rb
|
86
|
+
- lib/reflection_utils/create_class_methods_upon_include.rb
|
86
87
|
- lib/reflection_utils/version.rb
|
87
88
|
- reflection_utils.gemspec
|
88
89
|
homepage: https://github.com/thisismydesign/reflection_utils
|