inheritance-helper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 80340efe6c30e437ccf8d0096f09006c66718304efc3ecc6752392c2fd7e4e57
4
+ data.tar.gz: 7cb1b052663f71890dd0014c7ff0fad56b9998bf1bcb1bbbde59631e9971eaf6
5
+ SHA512:
6
+ metadata.gz: eae4098f0a2ec38626cec9ff96a193b3d105c3cab447e213217fa5fec155b8133e6d80f1029e68e9f260f6639f0146cfd2c458779c9dea7c2d32b5be0b8934b6
7
+ data.tar.gz: db2b843296110fbac9aa82366d371381ca5b41c3802a05dbc1a70dec9799dc81c69f5741c7768ecc39ad9641690ee1b8ce625db0f0b3e9810f3a8c51c9c78e37
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InheritanceHelper
4
+ module Methods
5
+ def self.redefine_class_method(klass, method, value)
6
+ class << klass; self; end.send(:define_method, method) { value }
7
+ klass
8
+ end
9
+
10
+ def redefine_class_method(method, value)
11
+ ::InheritanceHelper::Methods.redefine_class_method(self, method, value)
12
+ end
13
+
14
+ def add_value_to_class_method(method, value)
15
+ old_value = send(method)
16
+
17
+ new_value =
18
+ case old_value
19
+ when Hash
20
+ old_value.merge(value)
21
+ else
22
+ old_value + Array(value)
23
+ end
24
+
25
+ redefine_class_method(method, old_value.frozen? ? new_value.freeze : new_value)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InheritanceHelper
4
+ autoload :Methods, 'inheritance-helper/methods'
5
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inheritance-helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Doug Youch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Redefines class methods
14
+ email: dougyouch+github@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/inheritance-helper.rb
20
+ - lib/inheritance-helper/methods.rb
21
+ homepage: https://github.com/dougyouch/inheritance-helper
22
+ licenses: []
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.7.6
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Inheritance Helpers
44
+ test_files: []