konstructor 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/konstructor/core_ext.rb +1 -1
- data/lib/konstructor/exceptions.rb +1 -0
- data/lib/konstructor/factory.rb +1 -3
- data/lib/konstructor/konstructor_method_hook.rb +3 -1
- data/lib/konstructor/main.rb +12 -8
- data/lib/konstructor/simple_method_hook.rb +1 -0
- data/lib/konstructor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b268a5dc2f6be4998f6e18b900afc84d53ca9362
|
4
|
+
data.tar.gz: 102b9d190a66c3b93aa33dd76010f8a568294d26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21c464c814b1a1f17964a615b3f443040fffe97fe2406c7f9b2dc7fb2b7b9d509b92ba722305d81bbeae99666a6fed6bb4e59992ce9cb9c68b15efb36ed2ce72
|
7
|
+
data.tar.gz: b4dcf94cc6ff9ee49f1144aa2f89683480bd98a7beeb268ebf395932ef1c441153d9e40004fdc9ecd2cf0d004c2404ed1ceacbd3c4c2e93cdde50b7f340f3b2f
|
data/lib/konstructor/core_ext.rb
CHANGED
data/lib/konstructor/factory.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Konstructor
|
2
|
+
# :nodoc:
|
2
3
|
class Factory
|
3
4
|
|
4
5
|
def initialize(klass)
|
@@ -16,9 +17,6 @@ module Konstructor
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
# once method is a konstructor, it is always a konstructor, this differs
|
20
|
-
# from the way private, protected works, if overriding method isn't repeatedly marked as private
|
21
|
-
# it becomes public
|
22
20
|
def declared?(name)
|
23
21
|
declared_in_self?(name) || declared_in_superclass?(name)
|
24
22
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Konstructor
|
2
|
+
# :nodoc:
|
2
3
|
module KonstructorMethodHook
|
3
4
|
|
4
|
-
# Experimental and currently not used method_added
|
5
|
+
# Experimental and currently not used <code>method_added</code>
|
6
|
+
# hook approach protecting against method_added
|
5
7
|
# overrides that are not calling super (hopefully, there is no such code in the wild).
|
6
8
|
#
|
7
9
|
# Since method_added hook is idempotent, there would be no harm done even if
|
data/lib/konstructor/main.rb
CHANGED
@@ -8,6 +8,7 @@ module Konstructor
|
|
8
8
|
module KonstructorMethod
|
9
9
|
private
|
10
10
|
|
11
|
+
# :doc:
|
11
12
|
# konstructor -> nil
|
12
13
|
# konstructor(symbol, ...) -> nil
|
13
14
|
# konstructor(string, ...) -> nil
|
@@ -74,26 +75,29 @@ module Konstructor
|
|
74
75
|
DEFAULT_NAMES.include?(name.to_sym)
|
75
76
|
end
|
76
77
|
|
77
|
-
|
78
|
+
# Once method is a konstructor, it is always a konstructor, this differs
|
79
|
+
# from the way private, protected works. If overriding method isn't repeatedly
|
80
|
+
# marked as private it becomes public.
|
81
|
+
def declared?(klass, method_name)
|
78
82
|
konstructor = get_factory(klass)
|
79
83
|
if konstructor
|
80
|
-
konstructor.declared?(
|
84
|
+
konstructor.declared?(method_name.to_sym)
|
81
85
|
else
|
82
86
|
false
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
86
|
-
def declare(klass,
|
90
|
+
def declare(klass, new_method_names)
|
87
91
|
setup_method_added_hook(klass)
|
88
|
-
get_or_init_factory(klass).declare(
|
92
|
+
get_or_init_factory(klass).declare(new_method_names)
|
89
93
|
end
|
90
94
|
|
91
|
-
def method_added_to_klass(klass,
|
92
|
-
get_or_init_factory(klass).method_added_to_klass(
|
95
|
+
def method_added_to_klass(klass, method_name)
|
96
|
+
get_or_init_factory(klass).method_added_to_klass(method_name)
|
93
97
|
end
|
94
98
|
|
95
|
-
def is?(klass,
|
96
|
-
default?(
|
99
|
+
def is?(klass, method_name)
|
100
|
+
default?(method_name) || declared?(klass, method_name)
|
97
101
|
end
|
98
102
|
|
99
103
|
private
|
data/lib/konstructor/version.rb
CHANGED