sample_core_api 0.0.9.pre.1 → 0.0.9.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app_service.rb +1 -1
- data/lib/cassandra/cassandra_service.rb +1 -1
- data/lib/consul/consul_service.rb +1 -1
- data/lib/decoractors/authenticate.rb +1 -1
- data/lib/decoractors/valid.rb +1 -1
- data/lib/ioc/injector.rb +36 -38
- 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: 6e8d26257e1dff03d47b2f2d761d79ed22c0e7459388241bc03fe09af69e78ab
|
4
|
+
data.tar.gz: a442467264bc6e468fe53f26044ce7b6254127682facb5492ec061615c54c29a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af9ef71dcfea94340b3faadf6f581b7c7ebe3c9b32615e0c0a5dd7907d4fbf8a2d435b299c0a44b9da240c2f8d4f45f2a5e27012b572b9a8b8b632418a0d7332
|
7
|
+
data.tar.gz: 5d849c16e075502057246ae7690b2250e2d74fa954e8b5b1c90144db6a5b746672b3eac4fbe382ca16327dff20dd60e57c324248de5a0385adbc2983e365b0da
|
data/lib/app_service.rb
CHANGED
data/lib/decoractors/valid.rb
CHANGED
data/lib/ioc/injector.rb
CHANGED
@@ -2,52 +2,50 @@ require_relative "container"
|
|
2
2
|
require "dry/inflector"
|
3
3
|
|
4
4
|
Inflector = Dry::Inflector.new
|
5
|
-
|
5
|
+
|
6
|
+
def injector name = nil
|
6
7
|
name = name.nil? ? self.name[0, 1].downcase + self.name[1..-1] : name
|
7
|
-
|
8
|
-
Container.register(Inflector.underscore(name), instance_method)
|
8
|
+
Container.register(Inflector.underscore(name), self.extend(Injector).new)
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
module Injector
|
12
|
+
@@decorators = Hash.new
|
13
|
+
|
14
|
+
def decorators
|
15
|
+
@@decorators
|
16
|
+
end
|
17
|
+
|
18
|
+
def decorate name, decorators
|
19
|
+
if @@decorators[name].nil?
|
20
|
+
@@decorators[name] = []
|
21
|
+
end
|
22
|
+
@@decorators[name] = {:is_processed => false, :decorators => decorators}
|
23
|
+
end
|
14
24
|
|
15
|
-
|
16
|
-
|
25
|
+
def method_added(name)
|
26
|
+
super
|
27
|
+
orig_method = instance_method(name)
|
28
|
+
decorators = self.decorators[name]
|
29
|
+
return if decorators.nil? || decorators[:is_processed] == true
|
30
|
+
|
31
|
+
if private_method_defined?(name);
|
32
|
+
visibility = :private
|
33
|
+
elsif protected_method_defined?(name);
|
34
|
+
visibility = :protected
|
35
|
+
else
|
36
|
+
visibility = :public
|
17
37
|
end
|
18
38
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
@@decorators[name] = {:is_processed => false, :decorators => decorators}
|
39
|
+
decorators[:is_processed] = true
|
40
|
+
define_method(name) do |*args, &blk|
|
41
|
+
orig_method.bind(self).call(*args, &blk)
|
24
42
|
end
|
25
43
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if private_method_defined?(name);
|
33
|
-
visibility = :private
|
34
|
-
elsif protected_method_defined?(name);
|
35
|
-
visibility = :protected
|
36
|
-
else
|
37
|
-
visibility = :public
|
38
|
-
end
|
39
|
-
|
40
|
-
decorators[:is_processed] = true
|
41
|
-
define_method(name) do |*args, &blk|
|
42
|
-
orig_method.bind(self).call(*args, &blk)
|
43
|
-
end
|
44
|
-
|
45
|
-
case visibility
|
46
|
-
when :protected;
|
47
|
-
protected name
|
48
|
-
when :private;
|
49
|
-
private name
|
50
|
-
end
|
44
|
+
case visibility
|
45
|
+
when :protected;
|
46
|
+
protected name
|
47
|
+
when :private;
|
48
|
+
private name
|
51
49
|
end
|
52
50
|
end
|
53
51
|
end
|