eac_ruby_utils 0.114.0 → 0.115.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/lib/eac_ruby_utils/acts_as_abstract.rb +26 -5
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be84b8b3b5f7b60b56a999c8aa958747cf415dc143ed654f192bbcfd7b3d0d1d
|
4
|
+
data.tar.gz: ca5988e39fe2641aac05312f9ceb18d3a96c1a9d47491832a52a796c7df1a064
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b21dcf87a2778009eb8571d78aa533e0a1806603c7a298bb181dd0ce3a18cccec688fca12b45954d61abe590a22c538738a0ae570d21a61d03a002f9d4fe74a2
|
7
|
+
data.tar.gz: '099e597c3949a781819a89a9d8c57eaa246696ee50c7d42e93a56e5e8fb5c7111c68042ed3bc483b9e6db68622b1311622a99a9c3d360c3f9733a86f7003fa24'
|
@@ -35,13 +35,34 @@ module EacRubyUtils
|
|
35
35
|
end
|
36
36
|
|
37
37
|
module ClassMethods
|
38
|
+
# @param name [Symbol]
|
39
|
+
# @param arguments [Enumerable<Symbol>]
|
40
|
+
# @return [void]
|
41
|
+
def abstract_method(name, *arguments)
|
42
|
+
define_method name.to_sym do |*_the_args|
|
43
|
+
raise_abstract_method(name.to_sym, arguments)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param methods_names [Enumerable<Object>] Each item can be a symbolizable or a hash.
|
48
|
+
# @return [void]
|
38
49
|
def abstract_methods(*methods_names)
|
39
50
|
methods_names.each do |method_name|
|
40
|
-
|
41
|
-
|
51
|
+
if method_name.is_a?(::Hash)
|
52
|
+
abstract_methods_from_hash(method_name)
|
53
|
+
else
|
54
|
+
abstract_method(method_name)
|
42
55
|
end
|
43
56
|
end
|
44
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
# @param hash [Hash]
|
62
|
+
# @return [void]
|
63
|
+
def abstract_methods_from_hash(hash)
|
64
|
+
hash.each { |name, arguments| abstract_method(name, *arguments) }
|
65
|
+
end
|
45
66
|
end
|
46
67
|
|
47
68
|
module InstanceMethods
|
@@ -59,9 +80,9 @@ module EacRubyUtils
|
|
59
80
|
self.class.abstract_methods.include?(method_name.to_sym)
|
60
81
|
end
|
61
82
|
|
62
|
-
def raise_abstract_method(method_name)
|
63
|
-
raise ::NoMethodError, "Abstract method
|
64
|
-
" (Class: #{self.class})"
|
83
|
+
def raise_abstract_method(method_name, arguments = [])
|
84
|
+
raise ::NoMethodError, "Abstract method #{method_name}(#{arguments.join(', ')}) hit in " \
|
85
|
+
"#{self}\" (Class: #{self.class})"
|
65
86
|
end
|
66
87
|
end
|
67
88
|
end
|