tdc 0.4.3 → 0.4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tdc/generators/definition_sourcable.rb +10 -10
- data/lib/tdc/version.rb +1 -1
- 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: f01cdb5f72c9481d031888d6c1729d6ba6976c79184807dfeb4213fa3205ee99
|
4
|
+
data.tar.gz: 64ef598c74252a48925ad77c9f779df6c7a45957bb8b2cf641122981c9cfcc30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d093ea28c783c4a5b62c951c815cfb915c7ae7cf13ec2e97cb6ddaceedb09b968b6bb6bf9d80723d8146edac1c7bb6c562d59dec957d074cd67f985a0ce4c79f
|
7
|
+
data.tar.gz: c99360136e1857226fef356850499c8aa4bfbe5762c808ab115e4ca40bf4a8f9b097d06dc7c277e0b50e77e9655a2056dc544ca733552238c6de3b203b391c37
|
@@ -3,7 +3,10 @@ module Tdc
|
|
3
3
|
#
|
4
4
|
# Creates ghost methods for use in generators.
|
5
5
|
#
|
6
|
-
# All ghost methods are named 'key'_definition
|
6
|
+
# All ghost methods are named 'key'_definition or 'key'_definition_optional where 'key' is
|
7
|
+
# a key into the instance_definition hash.
|
8
|
+
#
|
9
|
+
# Choose optional if the key may not be present in the instance_definition.
|
7
10
|
#
|
8
11
|
# Example:
|
9
12
|
#
|
@@ -11,6 +14,7 @@ module Tdc
|
|
11
14
|
# ghost methods could be used to refer to the value associated with those keys:
|
12
15
|
#
|
13
16
|
# line_definition
|
17
|
+
# line_definition_optional
|
14
18
|
# replenishment_parameters_definition
|
15
19
|
#
|
16
20
|
module DefinitionSourcable
|
@@ -33,9 +37,9 @@ module Tdc
|
|
33
37
|
private
|
34
38
|
|
35
39
|
def method_missing(method, *args)
|
36
|
-
if
|
40
|
+
if ghost_definition?(method)
|
37
41
|
definition_source.fetch(method.to_s.gsub(/_definition$/, ""))
|
38
|
-
elsif
|
42
|
+
elsif ghost_optional_definition?(method)
|
39
43
|
definition_source[method.to_s.gsub(/_definition_optional$/, "")]
|
40
44
|
else
|
41
45
|
super
|
@@ -43,18 +47,14 @@ module Tdc
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def respond_to_missing?(method, include_all = false) # rubocop:disable Style/OptionalBooleanParameter
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def transform_method_to_definition_source_key(method)
|
50
|
-
method.to_s.gsub(/_definition$/, "")
|
50
|
+
ghost_definition?(method) || ghost_optional_definition?(method) ? true : super
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
53
|
+
def ghost_definition?(method)
|
54
54
|
method.to_s.end_with?("_definition")
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
57
|
+
def ghost_optional_definition?(method)
|
58
58
|
method.to_s.end_with?("_definition_optional")
|
59
59
|
end
|
60
60
|
end
|
data/lib/tdc/version.rb
CHANGED