dslblend 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dslblend/base.rb +18 -2
- 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: ef1b7e343e127a2b8235cda96b45387384cedca06b2970bc1f22c1c86bdf37b7
|
4
|
+
data.tar.gz: 4d241a1657d4c4061fd5a19cc6cf133194abe2d038c0c4e3125de31f89087aa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a30895d4f9305a45c3bb455d54d8270e766fcd51e39b4aa8b4016f49da0ba8712c9b4c408b75484b81248d1f7122004ffa440f2b4f4518c18fe3cef6a569e9b8
|
7
|
+
data.tar.gz: dc53c5878eb746849cba89ae388f4fb935639e8ea37ef6248c2ddc160a7e4a5d94cff995ccbb53c297a63c22f3533ee9b728f9ab43267a51b078e24dfe634180
|
data/lib/dslblend/base.rb
CHANGED
@@ -6,13 +6,29 @@ module Dslblend
|
|
6
6
|
@_additional_providers = additional_providers
|
7
7
|
end
|
8
8
|
|
9
|
-
def evaluate(&block)
|
9
|
+
def evaluate(backfire_vars: false, &block)
|
10
|
+
# Auto-detect main provider if it is not given yet
|
10
11
|
@_main_provider ||= eval 'self', block.binding, __FILE__, __LINE__
|
12
|
+
|
13
|
+
# Transfer instance variables from main provider instance to dsl instance, ignore those starting with "_"
|
11
14
|
@_main_provider.instance_variables.each do |instance_variable|
|
12
15
|
next if instance_variable.to_s.start_with?('@_')
|
13
16
|
instance_variable_set(instance_variable, @_main_provider.instance_variable_get(instance_variable))
|
14
17
|
end
|
15
|
-
|
18
|
+
|
19
|
+
# Evaluate block within the DSL
|
20
|
+
block_return_value = instance_eval(&block)
|
21
|
+
|
22
|
+
# If backfire is enabled, transfer dsl instance variables back to main provider instance, ignore those starting with "_"
|
23
|
+
if backfire_vars
|
24
|
+
instance_variables.each do |instance_variable|
|
25
|
+
next if instance_variable.to_s.start_with?('@_')
|
26
|
+
|
27
|
+
@_main_provider.instance_variable_set(instance_variable, instance_variable_get(instance_variable))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
return block_return_value
|
16
32
|
end
|
17
33
|
|
18
34
|
def method_missing(method, *args, &block)
|