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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffbc9ce42646170555907763750ce5bc3f538eb679f44b77340eb5567b796b68
4
- data.tar.gz: af2c9277493b7ce60deeb45bff4c58cd82965b06c2c96f547b31dd912d043051
3
+ metadata.gz: 6e8d26257e1dff03d47b2f2d761d79ed22c0e7459388241bc03fe09af69e78ab
4
+ data.tar.gz: a442467264bc6e468fe53f26044ce7b6254127682facb5492ec061615c54c29a
5
5
  SHA512:
6
- metadata.gz: 072f69955dbc3e9765a38a61958b77e9d5ea09d864329bcbc839fe28fef266419088b2400086bb72249738dc1b27f95542f7b10bd6a7e3c1c11b7ee90819221d
7
- data.tar.gz: fded44fd29b6edfd37c0f5cfb8fc0f7eef22b86268ab8976c5bdf92d560cb0ab7a629b2e4ddffef87da1e7cae8f39f6124b0fca68a6c02eb79d8482c4725baf3
6
+ metadata.gz: af9ef71dcfea94340b3faadf6f581b7c7ebe3c9b32615e0c0a5dd7907d4fbf8a2d435b299c0a44b9da240c2f8d4f45f2a5e27012b572b9a8b8b632418a0d7332
7
+ data.tar.gz: 5d849c16e075502057246ae7690b2250e2d74fa954e8b5b1c90144db6a5b746672b3eac4fbe382ca16327dff20dd60e57c324248de5a0385adbc2983e365b0da
data/lib/app_service.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require_relative 'consul/consul_service'
2
2
  require_relative 'cassandra/cassandra_service'
3
3
 
4
- class AppService < Injector
4
+ class AppService
5
5
  include Inject['consul_service', 'cassandra_service']
6
6
 
7
7
  injector
@@ -2,7 +2,7 @@ require 'cassandra'
2
2
  require_relative '../ioc/injector'
3
3
  require_relative 'abstracted_cassandra_repository'
4
4
 
5
- class CassandraService < Injector
5
+ class CassandraService
6
6
  include ::AbstractedCassandraRepository
7
7
 
8
8
  injector
@@ -3,7 +3,7 @@ require_relative '../ioc/injector'
3
3
  require_relative 'consul_configuration'
4
4
  require_relative '../rest/rest_service'
5
5
 
6
- class ConsulService < Injector
6
+ class ConsulService
7
7
  extend ConsulConfiguration
8
8
 
9
9
  injector
@@ -1,7 +1,7 @@
1
1
  require_relative '../ioc/injector'
2
2
  require_relative '../security/security_context_holder'
3
3
 
4
- class Authenticator < Injector
4
+ class Authenticator
5
5
 
6
6
  injector
7
7
 
@@ -1,6 +1,6 @@
1
1
  require_relative '../ioc/injector'
2
2
 
3
- class Validator < Injector
3
+ class Validator
4
4
 
5
5
  injector
6
6
 
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
- def injector name=nil, instance_method=nil
5
+
6
+ def injector name = nil
6
7
  name = name.nil? ? self.name[0, 1].downcase + self.name[1..-1] : name
7
- instance_method = instance_method.nil? ? self.new : instance_method
8
- Container.register(Inflector.underscore(name), instance_method)
8
+ Container.register(Inflector.underscore(name), self.extend(Injector).new)
9
9
  end
10
10
 
11
- class Injector
12
- class << self
13
- @@decorators = Hash.new
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
- def decorators
16
- @@decorators
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
- def decorate name, decorators
20
- if @@decorators[name].nil?
21
- @@decorators[name] = []
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
- def method_added(name)
27
- super
28
- orig_method = instance_method(name)
29
- decorators = self.decorators[name]
30
- return if decorators.nil? || decorators[:is_processed] == true
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sample_core_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9.pre.1
4
+ version: 0.0.9.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fusin Thang