corindon 0.4.0 → 0.5.0

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: fdda7809de8ba754d34b1ee6c90af75e23b9700450aa889651859a23ef54aa4d
4
- data.tar.gz: f1df008ae51c1fbe48a1a9554dc6be740d2012525106e0c2aadc41e3737ac651
3
+ metadata.gz: 37d5ac638b45a7b98ffa07c588b299147ae04ad8172eb9ac3d84f6b207242df7
4
+ data.tar.gz: 867092edd58ca1209d5bdfd3fd27d97f7663e63813c6266937e55b4eaa26bc8f
5
5
  SHA512:
6
- metadata.gz: d8f2c9c05289f1767bdab134dc959a159540bdd6653622b26d7515bad28010c0b052ac978ed555b37772b70be9ac9b2b108e8124060ff271c2517b4672d5b72a
7
- data.tar.gz: 3ae05c3677e98b24da5c7bf3f13a879d0f1e1350ec49953108cc9c9b16423928c93555dc07b38da55898005e1e43eaffc821dafcef823aaa4d0432267283a016
6
+ metadata.gz: a18f25be1501b07dab913c482f1b84308d392355182f02bc724bfc7dece28227c9aac87c7ecf6fb2bca2934019188968f9b177832303c9e7f8716254409dc0a8
7
+ data.tar.gz: ca432ab9e27df7b318052cc755d7b5f65b0b3e1bf42c6a1fae7043d27400b3108e148274ea0c862f64a5db6b3121cac3db449f9fb8cb8335aabeb4a536972151
@@ -21,11 +21,11 @@ module Corindon
21
21
 
22
22
  # @param [Class] klass
23
23
  # @return [String]
24
- def add_definition(klass, id: nil, anonymous: false, &block)
24
+ def add_definition(klass, id: nil, anonymous: false, context: {}, &block)
25
25
  definition = if injectable?(klass)
26
26
  klass.definition
27
27
  elsif block.sth?
28
- Dsl.new(klass).exec(&block)
28
+ Dsl.new(klass).exec(context: context, &block)
29
29
  else
30
30
  Definition.new(klass)
31
31
  end
@@ -60,6 +60,11 @@ module Corindon
60
60
  definitions.key?(to_id(key))
61
61
  end
62
62
 
63
+ # Clears all the cache of services
64
+ def clear
65
+ @services = {}
66
+ end
67
+
63
68
  # @param [Class, #to_s] key
64
69
  # @return [Object]
65
70
  def get(key)
@@ -14,9 +14,14 @@ module Corindon
14
14
  @anonymous = anonymous
15
15
  end
16
16
 
17
+ # @param [Hash] context
17
18
  # @return [Definition]
18
- def exec(&block)
19
- instance_exec(&block)
19
+ def exec(context: {}, &block)
20
+ if context.is_a?(Hash)
21
+ context = OpenStruct.new(context)
22
+ end
23
+
24
+ instance_exec(context, &block)
20
25
 
21
26
  Definition.new(@klass, args: @args, kwargs: @kwargs, calls: @calls, tags: @tags, id: @id, anonymous: @anonymous)
22
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Corindon
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corindon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Piotaix