inheritance-helper 0.1.5 → 0.2.5
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/lib/inheritance-helper.rb +4 -0
- data/lib/inheritance-helper/class_builder/utils.rb +34 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 562ea69d6c46e724638823857ec7df66ec87408b00c541cd63ce34f69fd9f1e7
|
4
|
+
data.tar.gz: 806d2e7ba749dd237e4588794d393aaaf29b76b9c54f41d7174335145d51326b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cb15000be0f56dd9a8fb48881d7766a07aee34d4330a67c049cbb8370646cccdf4d3a3d6c63f321b18dca91b9bd89ae103a6c9d0f93b339c193f3292a498d95
|
7
|
+
data.tar.gz: 865ea2dbce6c43fdd02424e6936bf385d14e61e5ca5b8904a35f7e628bf142cc2ed332c6d66235789330839522cef3e1d8379b7d37a8e5154b069bb92637de4f
|
data/lib/inheritance-helper.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module InheritanceHelper
|
4
|
+
# Utility methods for building dynamic classes
|
5
|
+
module ClassBuilder
|
6
|
+
module Utils
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def get_class_name(name, preffix_class_name, postfix_class_name)
|
10
|
+
name = name.to_s
|
11
|
+
|
12
|
+
class_name =
|
13
|
+
if name.respond_to?(:classify)
|
14
|
+
name.classify
|
15
|
+
else
|
16
|
+
# simple naive method to convert a string to a class name
|
17
|
+
name.gsub(/(^.|_.)/) { |_| ($1[1] || $1[0]).upcase }
|
18
|
+
end
|
19
|
+
|
20
|
+
preffix_class_name.to_s + class_name + postfix_class_name.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
# Purpose to create a class that is under a module with an actual class name
|
24
|
+
def create_class(base_module, name, base_class, preffix_class_name, postfix_class_name, &block)
|
25
|
+
class_name = get_class_name(name, preffix_class_name, postfix_class_name)
|
26
|
+
kls = base_class ? Class.new(base_class) : Class.new
|
27
|
+
base_module.const_set(class_name, kls)
|
28
|
+
kls = base_module.const_get(class_name)
|
29
|
+
kls.class_eval(&block) if block
|
30
|
+
kls
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
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.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Redefines class methods
|
14
14
|
email: dougyouch+github@gmail.com
|
@@ -17,12 +17,13 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/inheritance-helper.rb
|
20
|
+
- lib/inheritance-helper/class_builder/utils.rb
|
20
21
|
- lib/inheritance-helper/methods.rb
|
21
22
|
homepage: https://github.com/dougyouch/inheritance-helper
|
22
23
|
licenses:
|
23
24
|
- MIT
|
24
25
|
metadata: {}
|
25
|
-
post_install_message:
|
26
|
+
post_install_message:
|
26
27
|
rdoc_options: []
|
27
28
|
require_paths:
|
28
29
|
- lib
|
@@ -37,8 +38,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
38
|
- !ruby/object:Gem::Version
|
38
39
|
version: '0'
|
39
40
|
requirements: []
|
40
|
-
rubygems_version: 3.
|
41
|
-
signing_key:
|
41
|
+
rubygems_version: 3.2.3
|
42
|
+
signing_key:
|
42
43
|
specification_version: 4
|
43
44
|
summary: Inheritance Helpers
|
44
45
|
test_files: []
|