reflection_utils 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c261c1b2f2134c6a7df86853710ea69c54130244
4
- data.tar.gz: 74857503c77afc6d67ee3a34a29c226c41a15c68
3
+ metadata.gz: cb3c338cb45479816001814af0976ffcfe096316
4
+ data.tar.gz: c5c24aa8cb57aade4ab2816159e444198640bdfe
5
5
  SHA512:
6
- metadata.gz: d4b3884f9b9f0ac2b85c35e33ddfa255d249ba5c0aaa01cbd6abe3f420b4fb080e7319316a9a203815a72cb733acc9a85cbc0c554b00e3f386a283e6c273aba0
7
- data.tar.gz: 8d38855ac7793b6a09744506244e0345f53eba44df0ece32a24f930fe76ef18686783f5d9c89e1ee27241d71a217830bf43bf2564def47af8754922a79304a06
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
 
@@ -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
@@ -0,0 +1,9 @@
1
+ module ReflectionUtils
2
+ module CreateClassMethodsUponInclude
3
+ def self.included(base)
4
+ base.define_singleton_method :included do |base|
5
+ base.extend(self)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module ReflectionUtils
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  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.1.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 00:00:00.000000000 Z
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