inheritance-helper 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inheritance-helper.rb +1 -0
- data/lib/inheritance-helper/methods.rb +10 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0f85893db0cee390f4b58baef82b83bb11d082c6d7d3780d58de9cd8229e43c
|
4
|
+
data.tar.gz: 232920ab9049c25601cb2ec27240ceecb0978896e4e72e774ee51e93059081a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ec786e803b3cb1ef0df9382bb590fa599e61a310d749094c538a1e21562f4b7ad75d3208a8611c172cf74e132aa5153916b010ed66efcecde1b3ecb4fb399b1
|
7
|
+
data.tar.gz: 7b86cb3dfd5cce00deeb15ea469a19e2743505cef16797cc17942a243670d26f80b5868d126d2a3456c113af5493b6529d3cc35e5f40e660e5b92066bda12d86
|
data/lib/inheritance-helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module InheritanceHelper
|
4
|
+
# Collection of utility methods for rewriting class methods
|
4
5
|
module Methods
|
5
6
|
def self.redefine_class_method(klass, method, value)
|
6
7
|
class << klass; self; end.send(:define_method, method) { value }
|
@@ -11,6 +12,8 @@ module InheritanceHelper
|
|
11
12
|
::InheritanceHelper::Methods.redefine_class_method(self, method, value)
|
12
13
|
end
|
13
14
|
|
15
|
+
# useful for adding data to hashes.
|
16
|
+
# when working with arrays it keeps a flat data set
|
14
17
|
def add_value_to_class_method(method, value)
|
15
18
|
old_value = send(method)
|
16
19
|
|
@@ -24,5 +27,12 @@ module InheritanceHelper
|
|
24
27
|
|
25
28
|
redefine_class_method(method, old_value.frozen? ? new_value.freeze : new_value)
|
26
29
|
end
|
30
|
+
|
31
|
+
# useful for working with arrays and maintain a list of values
|
32
|
+
def append_value_to_class_method(method, value)
|
33
|
+
old_value = send(method)
|
34
|
+
new_value = old_value.dup << value
|
35
|
+
redefine_class_method(method, old_value.frozen? ? new_value.freeze : new_value)
|
36
|
+
end
|
27
37
|
end
|
28
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inheritance-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Redefines class methods
|
14
14
|
email: dougyouch+github@gmail.com
|
@@ -19,7 +19,8 @@ files:
|
|
19
19
|
- lib/inheritance-helper.rb
|
20
20
|
- lib/inheritance-helper/methods.rb
|
21
21
|
homepage: https://github.com/dougyouch/inheritance-helper
|
22
|
-
licenses:
|
22
|
+
licenses:
|
23
|
+
- MIT
|
23
24
|
metadata: {}
|
24
25
|
post_install_message:
|
25
26
|
rdoc_options: []
|
@@ -36,8 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
37
|
- !ruby/object:Gem::Version
|
37
38
|
version: '0'
|
38
39
|
requirements: []
|
39
|
-
|
40
|
-
rubygems_version: 2.7.6
|
40
|
+
rubygems_version: 3.0.3
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Inheritance Helpers
|